【发布时间】: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 <class:Application>': uninitialized constant Sass::Plugin (NameError)
【问题讨论】:
标签: ruby-on-rails-3 compass-sass