こちらのボタンを押しても反応しません。モーダル等も試しましたが、同じくボタンを押しても、モーダルが表示されることはありませんでした。
index.html.erb
ruby
1<h1>Pages#index</h1> 2<p>Find me in app/views/pages/index.html.erb</p> 3<p> 4 <a class="btn btn-primary" data-bs-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample"> 5 Link with href 6 </a> 7 <button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample"> 8 Button with data-bs-target 9 </button> 10</p> 11<div class="collapse" id="collapseExample"> 12 <div class="card card-body"> 13 Some placeholder content for the collapse component. This panel is hidden by default but revealed when the user activates the relevant trigger. 14 </div> 15</div>
Gemfile
ruby
1source 'https://rubygems.org' 2git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 4ruby '2.6.5' 5 6# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 7gem 'rails', '~> 5.2.5' 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' 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# gem 'mini_racer', platforms: :ruby 18gem 'bootstrap', '~> 4.6.0' 19gem 'jquery-rails' 20# Use CoffeeScript for .coffee assets and views 21gem 'coffee-rails', '~> 4.2' 22# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 23gem 'turbolinks', '~> 5' 24# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 25gem 'jbuilder', '~> 2.5' 26# Use Redis adapter to run Action Cable in production 27# gem 'redis', '~> 4.0' 28# Use ActiveModel has_secure_password 29# gem 'bcrypt', '~> 3.1.7' 30 31# Use ActiveStorage variant 32# gem 'mini_magick', '~> 4.8' 33 34# Use Capistrano for deployment 35# gem 'capistrano-rails', group: :development 36 37# Reduces boot times through caching; required in config/boot.rb 38gem 'bootsnap', '>= 1.1.0', require: false 39 40group :development, :test do 41 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 42 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 43end 44 45group :development do 46 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 47 gem 'web-console', '>= 3.3.0' 48 gem 'listen', '>= 3.0.5', '< 3.2' 49 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 50 gem 'spring' 51 gem 'spring-watcher-listen', '~> 2.0.0' 52end 53 54group :test do 55 # Adds support for Capybara system testing and selenium driver 56 gem 'capybara', '>= 2.15' 57 gem 'selenium-webdriver' 58 # Easy installation and use of chromedriver to run system tests with Chrome 59 gem 'chromedriver-helper' 60end 61 62# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 63gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
application.html.erb
ruby
1<!DOCTYPE html> 2<html> 3 <head> 4 <title>Forple</title> 5 <%= csrf_meta_tags %> 6 <%= csp_meta_tag %> 7 8 <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> 9 <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> 10 </head> 11 12 <body> 13 <%= yield %> 14 </body> 15</html>
application.js
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 rails-ujs 17//= require activestorage 18//= require turbolinks 19//= require_tree .
application.scss
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@import "bootstrap";
試したこと
・turbolinksの削除
参考記事:https://yurutsubu.com/rails-5-x-javascript-does-not-work-well-6745.html
その他参考記事:https://teratail.com/questions/151096
jQueryの導入が間違っているのでしょうか。お手数ですが、ご教授いただけないでしょうか?
あなたの回答
tips
プレビュー