开发者

Haml installation in Rails app failing

I have a small rails app I got all gung-ho on tonight wanting to convert all the erb to haml templates. The Haml docs suggest running haml --rails /path/to/app to install it as a plugin (using the gem already installed on the system).

Unfortunately, when I attempt to start the webserver for rails, I开发者_高级运维 receive the following error:

/code/src/myapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:443:in `load_missing_constant': uninitialized constant Haml (NameError)
    from /code/src/myapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in `const_missing'
    from /code/src/myapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:92:in `const_missing'
    from /code/src/myapp/config/environment.rb:15
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:111:in `run'
    from /code/src/myapp/config/environment.rb:5
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    from /code/src/myapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
    from /code/src/myapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /code/src/myapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
    from /code/src/myapp/vendor/rails/railties/lib/commands/server.rb:84
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    from ./script/server:3

It's barfing on a line in my environment file:

# Be sure to restart your server when you modify this file
RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
require File.join(File.dirname(__FILE__), 'boot')

Rails::Initializer.run do |config|
  # Add additional load paths for your own custom dirs
  config.load_paths += %W(
    #{RAILS_ROOT}/lib/
  )

  # Specify gems that this application depends on and have them installed with rake gems:install
  config.gem 'twitter'
  config.gem 'newrelic_rpm'

  Haml::Template.options[:format] = :html5
  Haml::Template.options[:attr_wrapper] = '"'

  config.plugins = [ :all ]
  config.active_record.observers = :user_observer
  config.time_zone = 'UTC' # "rake -D time" for all time zone names.
end

ConsumerConfig = YAML.load(File.read(Rails.root + 'config' + 'twitter-auth.yml'))

The error is on the line attempting to set some Haml options (Haml::Template.options[:format] = :html5). Installing the haml plugin with script/plugin install yields the same error, as does require haml at the top of environment.rb. Not sure if it makes a difference, but rails is frozen in vendor/rails.

This is very confusing to me, please assist if you can figure this out.


Does it work if you move the Haml::Template configuration after the Initializer block? It could be that Rails isn't loading the plugin until after the initializer is run.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜