开发者

Can't run rails server after installing custom-err-msg

After I install the custom-err-msg plugin, I get an error when I try to run rails server:

$ rails server
=> Booting WEBrick
=> Rails 3.0.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/jason/rails/snip/vendor/plugins/custom-err-msg/init.rb:3: uninitialized constant ActiveRecord::Errors (NameError)
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/plugin.rb:81
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `run_initializers'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
    from /usr/lib/ru开发者_JAVA百科by/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `send'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
    from /home/jason/rails/snip/config/environment.rb:5
    from /home/jason/rails/snip/config.ru:3:in `require'
    from /home/jason/rails/snip/config.ru:3
    from /usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/builder.rb:46:in `instance_eval'
    from /usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/builder.rb:46:in `initialize'
    from /home/jason/rails/snip/config.ru:1:in `new'
    from /home/jason/rails/snip/config.ru:1

Any idea why this is happening?


Here's an updated version that will work with Rails 3.

https://github.com/seansawyer/custom-err-msg

To fix the undefined method keys for nil:NilClass error, a method in lib/custom_error_message.rb needs to be changed to this:

def starts_with_humanized_column_followed_by_circumflex?(message)
  keys.any? do |column| 
    humanized = @base.class.human_attribute_name column.to_s.split('.').last.to_s
    message.match(/^#{humanized} \^/)
  end
end

Someone, please send him a pull request!


This plugin is not compatible with Rails 3. I would recommend finding a fork that is or forking it and updating yourself.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜