引导css定制和javascript未加载(Ruby 1.9.3p547,Rails 4.1.4)
我现在正在构建一个基本的RoR应用程序,但是在我的开发和生产环境中,我无法对boostrap css进行定制,javascript也没有加载(不过是在主页上为我的JW播放器加载的)。例如,当我试图删除文件时,下拉功能对导航栏不起作用,“销毁”功能也不起作用 这是我的档案:引导css定制和javascript未加载(Ruby 1.9.3p547,Rails 4.1.4),javascript,ruby,twitter-bootstrap,ruby-on-rails-4,Javascript,Ruby,Twitter Bootstrap,Ruby On Rails 4,我现在正在构建一个基本的RoR应用程序,但是在我的开发和生产环境中,我无法对boostrap css进行定制,javascript也没有加载(不过是在主页上为我的JW播放器加载的)。例如,当我试图删除文件时,下拉功能对导航栏不起作用,“销毁”功能也不起作用 这是我的档案: source 'https://rubygems.org' ruby '2.0.0' # Bundle edge Rails instead: gem 'rails', github: 'rails/
source 'https://rubygems.org'
ruby '2.0.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.2'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
gem 'bootstrap-sass'
gem 'devise', '~> 3.1.0.rc2'
gem 'rake', '~> 10.3.2'
gem 'jwplayer-rails', '~> 1.0.1'
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
*/-------------------------------------------------*/
Application.js:
//= require jwplayer.shuffle
//= require jwplayer.shuffle.min
//= require bootstrap
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
*/-------------------------------------------------*/
Application.css:
*= require_tree .
*= require_self
*/
*/-------------------------------------------------*/
I placed these css customizations in an scss file, which are not being recognized:
@import "bootstrap";
$body-bg: #ecf0f1;
$font-family-sans-serif: 'Lato', sans-serif;
$navbar-height: 110px;
$navbar-margin-bottom: 0px;
$navbar-default-bg: black;
$navbar-default-brand-color: #ffffff;
$brand-primary: #ff00ff;
$link-hover-color: #00ffff;
*/-------------------------------------------------*/
Application.html.rb file:
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
Development.rb file:
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end
*/-------------------------------------------------*/
Production.rb:
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = false
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Generate digests for assets URLs.
config.assets.digest = true
# `config.assets.precompile` has moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Set to :debug to see everything in the log.
config.log_level = :info
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com"
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# config.assets.precompile += %w( search.js )
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Disable automatic flushing of the log to improve performance.
# config.autoflush_log = false
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end
*/-------------------------------------------------*/
源代码'https://rubygems.org'
ruby“2.0.0”
#捆绑边缘Rails:gem'Rails',github'Rails/Rails'
gem“rails”、“4.0.2”
#将SCS用于样式表
gem'sass-rails',“~>4.0.0”
#使用Uglifier作为JavaScript资产的压缩器
gem'uglifier','>=1.3.0'
#将CoffeeScript用于.js.coffee资产和视图
gem“咖啡轨”,“~>4.0.0”
#看https://github.com/sstephenson/execjs#readme 获取更多受支持的运行时
#宝石“therubyracer”,平台::ruby
#使用jquery作为JavaScript库
gem'jqueryrails'
#Turbolinks使web应用程序中的以下链接更快。阅读更多:https://github.com/rails/turbolinks
gem“涡轮链接”
#轻松构建JSON API。阅读更多:https://github.com/rails/jbuilder
gem'jbuilder',“~>1.2”
gem‘引导式sass’
gem“设计”,“~>3.1.0.rc2”
gem'rake',“~>10.3.2”
gem'jwplayer rails',“~>1.0.1”
小组:开发,:测试
gem'sqlite3'
结束
小组:生产部
宝石“pg”
gem“rails_12factor”
结束
小组:doc do
#bundle exec rake doc:rails在doc/API下生成API。
gem“sdoc”,要求:false
结束
#使用ActiveModel具有\u安全\u密码
#宝石'bcrypt ruby',“~>3.1.2”
#使用unicorn作为应用程序服务器
#宝石“独角兽”
#使用Capistrano进行部署
#gem“capistrano”,集团::开发
#使用调试器
#gem'debugger',组:[:开发,:测试]
*/-------------------------------------------------*/
Application.js:
//=需要jwplayer.shuffle
//=需要jwplayer.shuffle.min
//=需要引导
//=需要jquery
//=需要jquery\u ujs
//=需要涡轮链路
//=需要一棵树。
*/-------------------------------------------------*/
Application.css:
*=需要一棵树。
*需要自己
*/
*/-------------------------------------------------*/
我将这些css自定义设置放在一个scss文件中,该文件无法识别:
@导入“引导”;
$body bg:#ecf0f1;
$font系列无衬线:'Lato',无衬线;
$navbar高度:110像素;
$navbar保证金底部:0px;
$navbar默认背景:黑色;
$navbar默认品牌颜色:#ffffff;
$brand primary:#ff00ff;
$link悬停颜色:#00ffff;
*/-------------------------------------------------*/
Application.html.rb文件:
正确%>
正确%>
Development.rb文件:
Rails.application.configure do
#此处指定的设置将优先于config/application.rb中的设置。
#在开发环境中,应用程序的代码将被重新加载
#每一个请求。这会减慢响应时间,但非常适合开发
#因为在进行代码更改时不必重新启动web服务器。
config.cache_classes=false
#不要急于在启动时加载代码。
config.eager\u load=false
#显示完整的错误报告并禁用缓存。
config.consive\u all\u requests\u local=true
config.action\u controller.perform\u caching=false
#如果邮递员发不来,你也不在乎。
config.action\u mailer.raise\u delivery\u errors=false
#将弃用通知打印到Rails记录器。
config.active\u support.deprecation=:log
#如果存在挂起的迁移,则在页面加载时引发错误。
config.active\u record.migration\u error=:page\u load
#调试模式禁用资源的连接和预处理。
#此选项可能会导致视图渲染过程中出现较大延迟
#复杂资产的数量。
config.assets.debug=true
#在运行时为资产提供服务时添加额外的错误检查。
#检查是否存在不正确声明的链轮相关性。
#引发有用的错误消息。
config.assets.raise\u runtime\u errors=true
#因缺少翻译而引发错误
#config.action\u view.raise\u on\u missing\u translations=true
结束
*/-------------------------------------------------*/
Production.rb:
Rails.application.configure do
#此处指定的设置将优先于config/application.rb中的设置。
#代码不会在请求之间重新加载。
config.cache_classes=true
#启动时立即加载代码。这将加载大部分Rails和
#您的应用程序在内存中,允许两个线程化web服务器
#而那些依靠写上拷贝来表现更好的人。
#Rake任务会自动忽略此选项以提高性能。
config.eager\u load=true
#完全错误报告被禁用,缓存被打开。
config.consive\u all\u requests\u local=false
config.action\u controller.perform\u caching=true
#启用Rack::Cache在应用程序前面放置一个简单的HTTP缓存
#在启用此功能之前,将“机架缓存”添加到您的文件中。
对于大规模生产使用,考虑使用缓存反向代理,如NGNIX,清漆或SQUID。
#config.action\u dispatch.rack\u cache=true
#禁用Rails的静态资产服务器(Apache或nginx已经可以这样做了)。
config.service\u static\u assets=false
#压缩Java脚本和CSS。
config.assets.js_compressor=:uglifier
#config.assets.css_compressor=:sass
#如果缺少预编译的资产,请不要回退到资产管道。
config.assets.compile=false
#为资源URL生成摘要。
config.assets.digest=true
#`config.assets.precompile`已移动到config/initializers/assets.rb
#指定服务器用于发送文件的标头。
#config.action\u dispatch.x\u sendfile\u header=“x-sendfile”