Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 Rails资产管道和Twitter引导程序_Ruby On Rails 3_Twitter Bootstrap_Asset Pipeline_Ruby On Rails 3.2_Sprockets - Fatal编程技术网

Ruby on rails 3 Rails资产管道和Twitter引导程序

Ruby on rails 3 Rails资产管道和Twitter引导程序,ruby-on-rails-3,twitter-bootstrap,asset-pipeline,ruby-on-rails-3.2,sprockets,Ruby On Rails 3,Twitter Bootstrap,Asset Pipeline,Ruby On Rails 3.2,Sprockets,我正在使用引导railsgem的最新主分支,并试图以与rails资产管道兼容的方式修改默认引导变量 我的gem文件包含了这些gem gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git' gem 'uglifier', '>= 1.0.3' gem 'less-rails-bootstrap' 我还在我的application.css文件中包含了*=

我正在使用引导railsgem的最新主分支,并试图以与rails资产管道兼容的方式修改默认引导变量

我的gem文件包含了这些gem

gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
gem 'uglifier', '>= 1.0.3'
gem 'less-rails-bootstrap'
我还在我的
application.css
文件中包含了
*=require bootstrap\u和\u overrides
。我知道链轮单独编译每个css文件,因此您不能期望多个css文件能够相互引用。因此,bootstrap_和_overrides.css.less文件包括以下内容:

@import "twitter/bootstrap/bootstrap";
body { padding-top: 80px; }

//background-image: asset-url("background.png"); background-repeat:no-repeat; background-size: cover;  }

@import "twitter/bootstrap/responsive";

// Set the correct sprite paths
@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');
@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png');

// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
@fontAwesomeEotPath: asset-path('fontawesome-webfont.eot');
@fontAwesomeWoffPath: asset-path('fontawesome-webfont.woff');
@fontAwesomeTtfPath: asset-path('fontawesome-webfont.ttf');
@fontAwesomeSvgzPath: asset-path('fontawesome-webfont.svgz');
@fontAwesomeSvgPath: asset-path('fontawesome-webfont.svg');

// Font Awesome
@import "fontawesome";

// Your custom LESS stylesheets goes here
//
// Since bootstrap was imported above you have access to its mixins which
// you may use and inherit here
//
// If you'd like to override bootstrap's own variables, you can do so here as well
// See http://twitter.github.com/bootstrap/less.html for their names and documentation
//
// Example:
// @linkColor: #ff0000;

@navbarHeight: 60px;
@navbarText: @white;
@textColor: @orange;
@navbarLinkColor: @white;
@navbarBackground: darken(@linkColor, 15%);
@navbarBackgroundHighlight: @linkColor;
但是,我的覆盖都不在资产管道下工作。没有它他们工作得很好。有人知道为什么吗

更新我的资产Gem组

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'less-rails'
  #  gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  gem 'therubyracer', :platform => :ruby
  gem 'uglifier', '>= 1.0.3'
end

在我的例子中,资产管道引擎查找资源的目录没有正确设置,导致资产没有正确编译

我正在使用引导式sass,所以您的情况可能会有所不同。但在我的例子中,将以下代码添加到application.rb解决了我的问题

module ApplicationModuleName
  class Application < Rails::Application

    config.sass.load_paths = []
    config.sass.load_paths << "#{Rails.root}/app/assets/stylesheets"
    %w(bootstrap-sass jstree-rails jquery-rails).each do |pkg|
      config.sass.load_paths << "#{Gem.loaded_specs[pkg].full_gem_path}/vendor/assets/stylesheets"
      config.assets.paths << "#{Gem.loaded_specs[pkg].full_gem_path}/vendor/assets/javascripts"
    end
  end
end
模块应用程序模块名
类应用程序config.sass.load_paths在部署之前运行
rake资产:在本地预编译
解决了我上面的问题。

我在rails 4.1和ruby 2.0中使用的引导较少,但我通过将其添加到application.css.scss中修复了这一问题

*= require_tree .
*= require bootstrap_and_overrides
*= require_self

您的资产组中是否有较少的rails gem?我有,更新了我的gem资产组的问题上述补丁无效,因为
sass
不是
config
的属性。我得到了以下错误:
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/railtie/configuration.rb:85:in-method#缺少:未定义的方法sass for#(NoMethodError)
我在上一篇文章中删除了模块和类包装器。正确编辑了示例。感谢分享您的方法,尽管我通过在部署之前在本地运行
rake assets:precompile
解决了我的问题,并且一切都得到了修复。很好。。那么,我想这不是我提到的加载路径问题。