#javascript #jquery #ruby-on-rails #twitter-bootstrap #webpacker
Вопрос:
Я пытаюсь использовать эти загрузочные JavaScripts в своем проекте с использованием rails 6.
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require turbolinks
//= require_tree .
в версии Rails 6 application.js файл был перемещен внутри пакетов.
в версиях Oder это было бы нормально, но в rails 6 я попытался, но это не сработало. Мой загрузочный Javascript не работал.
Как мне действительно требуются загрузочные JavaScripts в rails 6 и выше?
Пожалуйста, помогите мне, я застрял, я пытался добавить это, но это не сработало
, вот мой application.js файл
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require turbolinks
//= require_tree .
import Rails from "@rails/ujs"
import Turbolinks from "turbolinks"
import * as ActiveStorage from "@rails/activestorage"
import "channels"
import "bootstrap"
import "../stylesheets/application"
Rails.start()
Turbolinks.start()
ActiveStorage.start()
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels").start()
require("jquery").start()
require("bootstrap-sprockets").start()
require("jquery_ujs").start()
require("require_tree .").start()
Вот мой файл с драгоценными камнями
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '3.0.2'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem 'rails', '~> 6.1.4'
# Use Puma as the app server
gem 'puma', '~> 5.0'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 5.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Active Storage variant
# gem 'image_processing', '~> 1.2'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.4', require: false
# uSE TWITTER BOOTSTRAP LIBRARY FOR FRONT-END UI LAYOUT
gem 'bootstrap-sass', '3.3.7'
#Use Font Awesome sass gem for adding icons
gem 'font-awesome-sass', '4.6.2'
gem 'jquery-rails'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 4.1.0'
# Display performance information such as SQL time and flame graphs for each request in your browser.
# Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
gem 'rack-mini-profiler', '~> 2.0'
end
group :production do
#Use the PostgreSQL gem for Heroku Production Servers
gem 'pg', '0.18.4'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 3.26'
gem 'selenium-webdriver'
# Easy installation and use of web drivers to run system tests with browsers
gem 'webdrivers'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Комментарии:
1. Что я делаю не так? Пожалуйста, помогите мне.