Ruby on rails RubyonRails引导下拉列表正在开发中,但不是Heroku
我使用的是Ruby 2.4.1/Rails 5.1.6 我的引导导航栏中有下拉菜单。我最终让它们在我的开发环境中工作,但当它们被推到Heroku时就不工作了。这是我的application.js文件:Ruby on rails RubyonRails引导下拉列表正在开发中,但不是Heroku,ruby-on-rails,twitter-bootstrap,Ruby On Rails,Twitter Bootstrap,我使用的是Ruby 2.4.1/Rails 5.1.6 我的引导导航栏中有下拉菜单。我最终让它们在我的开发环境中工作,但当它们被推到Heroku时就不工作了。这是我的application.js文件: // //= require jquery //= require jquery_ujs //= require bootstrap-sprockets //= require turbolinks //= require_tree . 我从其他Stackoverflow的帖子中读到,一些人在重
//
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require turbolinks
//= require_tree .
我从其他Stackoverflow的帖子中读到,一些人在重新排列这个列表时运气不错。然而,这样做破坏了发展,这是不好的
这是我的档案:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
gem 'bootstrap-sass', '~> 3.3.7'
gem 'jquery-rails'
gem 'rails', '~> 5.1.4'
gem 'puma', '~> 3.7'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'bcrypt', '~> 3.1.7'
group :development, :test do
gem 'sqlite3'
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :production do
gem 'pg', '~> 0.18'
gem 'rails_12factor'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
custom.css.scss:
@import "bootstrap-sprockets";
@import "bootstrap";
.listing {
list-style: none;
padding-left: 0;
}
.username-link {
padding-top: 10px;
}
我还阅读了一些答案,其中预编译资产解决了这个问题,但是,这并没有为我解决这个问题(尽管这可能是帮助它在我的开发环境中工作的原因之一)
我试着清理我的饼干和历史作为一个戏剧性的步骤,但没有乐趣
我尝试直接将@imports添加到application.scss,而不是custom.css.scss
我已经删除了require rails\u ujs,因为它与require jquery\u ujs是冗余的
如有任何建议,我们将不胜感激 显然你错过了一些东西 在您的文件中,您需要添加
gem 'bootstrap-sass', '~> 3.3.7'
gem 'sass-rails', '>= 3.2'//This one you need
gem 'jquery-rails'
捆绑安装
并重新启动服务器
在app/assets/stylesheets/application.scss中导入引导样式:
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
* vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
@import "bootstrap-sprockets"; // suggested change from SO user.
@import "bootstrap"; // suggested change from SO user.
// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables"
@import "bootstrap-sprockets";
@import "bootstrap";
引导前必须导入引导链轮,图标字体才能正常工作
在app/assets/Javascripts/application.js中需要引导Javascripts:
//= require jquery
//= require bootstrap-sprockets
很明显你错过了一些东西 在您的文件中,您需要添加
gem 'bootstrap-sass', '~> 3.3.7'
gem 'sass-rails', '>= 3.2'//This one you need
gem 'jquery-rails'
捆绑安装
并重新启动服务器
在app/assets/stylesheets/application.scss中导入引导样式:
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
* vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
@import "bootstrap-sprockets"; // suggested change from SO user.
@import "bootstrap"; // suggested change from SO user.
// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables"
@import "bootstrap-sprockets";
@import "bootstrap";
引导前必须导入引导链轮,图标字体才能正常工作
在app/assets/Javascripts/application.js中需要引导Javascripts:
//= require jquery
//= require bootstrap-sprockets
从
application.js
中删除//=require-rails-ujs
,如果使用/=require-jquery\u-ujs
,则不需要此选项,请参见此
像这样
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require turbolinks
//= require_tree .
从
application.js
中删除//=require-rails-ujs
,如果使用/=require-jquery\u-ujs
,则不需要此选项,请参见此
像这样
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require turbolinks
//= require_tree .
我在这篇文章中找到了答案:。我试图使用
Heroku run--app NAMEOFAPP-rake-assets:precompile
直接在Heroku上预编译资产,而不是使用rake-assets:precompile-RAILS\u ENV=production
预编译资产,然后将生成的资产提交给GitHub
我不能确定一些建议的更改最终是否有用,所以感谢所有建议更改的人!很高兴能摆脱头痛。我在这篇较老的SO帖子中找到了答案:。我试图使用
Heroku run--app NAMEOFAPP-rake-assets:precompile
直接在Heroku上预编译资产,而不是使用rake-assets:precompile-RAILS\u ENV=production
预编译资产,然后将生成的资产提交给GitHub
我不能确定一些建议的更改最终是否有用,所以感谢所有建议更改的人!很高兴摆脱了这一困扰。尝试从应用程序中删除rails ujs。js谢谢您的回复!很遗憾,这并不能解决问题。请尝试从应用程序中删除rails ujs。js谢谢您的回复!不幸的是,这并不能解决问题。感谢您的快速回复!不幸的是,这并不能解决问题。很高兴学到了一些东西。谢谢你的快速回复!不幸的是,这并不能解决问题。很高兴学到了一些东西。谢谢你的快速回复!我用相关文件更新了这个问题。不幸的是,我似乎拥有这里的一切,但它仍然在Heroku上行为不端。唯一不同于你建议的是我有gem'sass-rails',“~>5.0”。这应该没问题,对吧?为了以防万一,尝试使用您建议的gem版本。没有解决问题,但值得一试。谢谢您的快速回复!我用相关文件更新了这个问题。不幸的是,我似乎拥有这里的一切,但它仍然在Heroku上行为不端。唯一不同于你建议的是我有gem'sass-rails',“~>5.0”。这应该没问题,对吧?为了以防万一,尝试使用您建议的gem版本。没有解决问题,但值得一试。