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

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

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

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

Ruby on Rails

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

データベース

データベースとは、データの集合体を指します。また、そのデータの集合体の共用を可能にするシステムの意味を含めます

Bootstrap

BootstrapはウェブサイトデザインやUIのWebアプリケーションを素早く 作成する可能なCSSフレームワークです。 Twitter風のデザインを作成することができます。

Q&A

0回答

680閲覧

nokogiriをインストールし、rails gでviewファイルを作成したら、他のレイアウトが崩れた

kobaryo04ysh

総合スコア29

Ruby

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

Ruby on Rails

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

データベース

データベースとは、データの集合体を指します。また、そのデータの集合体の共用を可能にするシステムの意味を含めます

Bootstrap

BootstrapはウェブサイトデザインやUIのWebアプリケーションを素早く 作成する可能なCSSフレームワークです。 Twitter風のデザインを作成することができます。

0グッド

1クリップ

投稿2020/02/13 13:01

ブログアプリを作成しているのですが、記事数が増えたときのために、gemのkaminariをインストールし、記事を自動生成するためにseeds.rbに

seeds.rb

1if Rails.env == 'development' 2 (1..50).each do |i| 3 Post.create(name: "ユーザー#{i}", body: "本文#{i}") 4 end 5end

と記載し、$bundle exec rails db:seedを実行し生成しました。

その後、$bundle exec rails g kaminari:configを行い、

$bundle exec rails g kaminari:views bootstrap4

を実行したら、レイアウトが崩れました。
application.jsでライブラリの書く順番を変えたり、application.scssの*= require_self
*= require_tree .を消したり追加したり、試したのですが、うまくいきませんでした。

崩れているレイアウトをchromeのデベロッパーツールで確認したところ、それまでbootstrapで整えていたはずのところが、application.self-xxxxxxxx...(番号)のようなファイルが読み込まれているようでした。

いかに、styleseetなどのファイルの中身を記述します。

application

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

application

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

Gemfile

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

どこをどうすれば、元に戻るのでしょうか。

よろしくお願い致します。

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

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

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

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

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

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問