質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

RubyGems

RubyGemsはRubyによるプログラミングのためのパッケージマネジメントツールです。ユーザはこれを使用することで、Rubyライブラリのダウンロードやアップデートや、依存関係の自動解決が可能になります。

Q&A

解決済

1回答

1011閲覧

Rail チュートリアルにてBootstrapが導入できない

t_54342134142

総合スコア11

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

RubyGems

RubyGemsはRubyによるプログラミングのためのパッケージマネジメントツールです。ユーザはこれを使用することで、Rubyライブラリのダウンロードやアップデートや、依存関係の自動解決が可能になります。

0グッド

0クリップ

投稿2018/10/12 06:53

Railsに挑戦中です。
Bootstrapを導入しようとして何度やり直してもエラーになってしまうのでお力をお貸しいただければと思います。

環境はドットインストールを真似してVagrantでやっています。

環境
・Mac OS high Sierra
・Rails 5.2.1
・ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
・Vagrant

Error

1Sass::SyntaxError in StaticPages#home 2Showing /home/vagrant/rails/myapp/app/views/layouts/application.html.erb where line #8 raised: 3 4File to import not found or unreadable: bootstrap. 5Load paths: 6 /home/vagrant/rails/myapp/app/assets/config 7 /home/vagrant/rails/myapp/app/assets/images 8 /home/vagrant/rails/myapp/app/assets/javascripts 9 /home/vagrant/rails/myapp/app/assets/stylesheets 10 /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/coffee-rails-4.2.2/lib/assets/javascripts 11 /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actioncable-5.2.1/lib/assets/compiled 12 /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activestorage-5.2.1/app/assets/javascripts 13 /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actionview-5.2.1/lib/assets/compiled 14 /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/turbolinks-source-5.2.0/lib/assets/javascripts 15 /home/vagrant/rails/myapp/node_modules 16 17Extracted source (around line #17): 18@import "bootstrap"; 19 20Rails.root: /home/vagrant/rails/myapp 21

Gemfile

1source 'https://rubygems.org' 2git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 4ruby '2.3.1' 5 6# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 7gem 'rails', '~> 5.2.1' 8# Use sqlite3 as the database for Active Record 9gem 'sqlite3' 10# Use Puma as the app server 11gem 'puma', '~> 3.11' 12# Use SCSS for stylesheets 13gem 'sass-rails', '~> 5.0' 14# Use Uglifier as compressor for JavaScript assets 15gem 'uglifier', '>= 1.3.0' 16# See https://github.com/rails/execjs#readme for more supported runtimes 17 18gem 'bootstrap', '~> 4.0.0' 19 20# Use jquery as the JavaScript library 21gem 'jquery-rails' 22# Use CoffeeScript for .coffee assets and views 23gem 'coffee-rails', '~> 4.2' 24# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 25gem 'turbolinks', '~> 5' 26# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 27gem 'jbuilder', '~> 2.5' 28# Use Redis adapter to run Action Cable in production 29# gem 'redis', '~> 4.0' 30# Use ActiveModel has_secure_password 31# gem 'bcrypt', '~> 3.1.7' 32 33gem 'therubyracer' 34gem 'autoprefixer-rails', '8.6.5' 35 36# Use ActiveStorage variant 37# gem 'mini_magick', '~> 4.8' 38 39# Use Capistrano for deployment 40# gem 'capistrano-rails', group: :development 41 42# Reduces boot times through caching; required in config/boot.rb 43gem 'bootsnap', '>= 1.1.0', require: false 44 45group :development, :test do 46 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 47 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 48end 49 50group :development do 51 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 52 gem 'web-console', '>= 3.3.0' 53 gem 'listen', '>= 3.0.5', '< 3.2' 54 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 55 gem 'spring' 56 gem 'spring-watcher-listen', '~> 2.0.0' 57end 58 59group :test do 60 # Adds support for Capybara system testing and selenium driver 61 gem 'capybara', '>= 2.15' 62 gem 'selenium-webdriver' 63 # Easy installation and use of chromedriver to run system tests with Chrome 64 gem 'chromedriver-helper' 65end 66 67# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 68gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 69

scss

1/* 2 * This is a manifest file that'll be compiled into application.css, which will include all the files 3 * listed below. 4 * 5 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's 6 * vendor/assets/stylesheets directory can be referenced here using a relative path. 7 * 8 * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS 10 * files in this directory. Styles in this file should be added after the last require_* statement. 11 * It is generally better to create a new file per style scope. 12 * 13 */ 14 15 16@import "bootstrap";

js

1// This is a manifest file that'll be compiled into application.js, which will include all the files 2// listed below. 3// 4// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's 5// vendor/assets/javascripts directory can be referenced here using a relative path. 6// 7// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8// compiled file. JavaScript code in this file should be added after the last require_* statement. 9// 10// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11// about supported directives. 12// 13//= require jquery3 14//= require popper 15//= require bootstrap-sprockets 16//= require jquery_ujs 17//= require turbolinks 18//= require_tree .

html

1 2<!DOCTYPE html> 3<html> 4 <head> 5 <title>Myapp</title> 6 <%= csrf_meta_tags %> 7 <%= csp_meta_tag %> 8 9 <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> 10 <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> 11 </head> 12 13 <body> 14 <%= yield %> 15 </body> 16</html> 17

色々試してみたのですが、HTMLのこの部分を削除するとかろうじて動く程度のことしかわかりませんでした。

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>

長文ですが、よろしくお願い致します。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

bundle installしてなければ実行してください。
もしbundle installしていて出るならサーバ再起動で直ることがあるようです。

投稿2018/10/12 06:59

dice142

総合スコア5158

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

t_54342134142

2018/10/13 07:43

再起動したら直りました!ありがとうございます!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問