【问题标题】:rails3 with compass-railsrails3 带指南针导轨
【发布时间】:2012-02-06 19:20:48
【问题描述】:

我正在尝试使用新的 compass-rails gem 设置 rails 3.2 应用程序

https://github.com/Compass/compass-rails

我想用 compass watch 命令编译 assets 文件夹中的文件——因为我想部署到 heroku,但到目前为止我没有成功。

compass-rails gem 页面指出:

使用 Compass watcher 开发

使用 Compass watcher 更新样式表时,您的样式表会在您保存 Sass 文件后立即重新编译。在这种模式下,编译后的样式表将被写入项目的公共文件夹,因此将直接由项目的 Web 服务器提供服务——取代正常的 Rails 编译。

在这种模式下,rails 3.0 或更早版本的用户将通过禁用 Sass::Plugin 来体验轻微的加速,如下所示:

config.after_initialize do
  Sass::Plugin.options[:never_update] = true
end

但我不知道在哪里放置此配置选项

有什么想法吗?

==编辑==

我尝试在我的 application.rb 中添加 config.after_initialize 块

require File.expand_path('../boot', __FILE__)

# require 'rails/all'
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
# require "sprockets/railtie"


if defined?(Bundler)
  # If you precompile assets before deploying to production, use this line
  Bundler.require(*Rails.groups(:assets => %w(development test)))
  # If you want your assets lazily compiled in production, use this line
  # Bundler.require(:default, :assets, Rails.env)
end

module Salsacaribecouk
  class Application < Rails::Application

    # Configure the default encoding used in templates for Ruby 1.9.
    config.encoding = "utf-8"

    # Configure sensitive parameters which will be filtered from the log file.
    config.filter_parameters += [:password]


    # Enable the asset pipeline
    config.assets.enabled = true

    # Version of your assets, change this if you want to expire all your assets
    config.assets.version = '1.0'

    config.after_initialize do
      Sass::Plugin.options[:never_update] = true
    end
  end
end

但是当我运行 rails 服务器时,我收到一条错误消息:

block in &lt;class:Application&gt;': uninitialized constant Sass::Plugin (NameError)

【问题讨论】:

    标签: ruby-on-rails-3 compass-sass


    【解决方案1】:

    config.after_initialize如果要在所有环境中执行,则应放在config\application.rb中,或者在config\environments\[development|test|production].rb中以在特定环境中执行。

    【讨论】:

    • 我把它放在模块 myapp \r 类应用程序
    • 是的,与其他config.XXX 指令处于同一级别
    • 试过了,但我收到一条错误消息,sass::plugin unialized constant
    • 看看stackoverflow.com/questions/7300815/…的回答,可能会有帮助。
    猜你喜欢
    • 1970-01-01
    • 2012-06-16
    • 2013-09-10
    • 1970-01-01
    • 1970-01-01
    • 2014-09-25
    • 2011-07-26
    • 1970-01-01
    • 2012-12-18
    相关资源
    最近更新 更多