NoMethodError (undefined method `file_exists?’ for #

阅读更多
NoMethodError (undefined method `file_exists?’ for #):
/usr/lib64/ruby/gems/1.8/gems/gettext-1.90.0/lib/gettext/rails.rb:280:in `render_file’
/usr/lib64/ruby/gems/1.8/gems/gettext-1.90.0/lib/gettext/rails.rb:278:in `each’
/usr/lib64/ruby/gems/1.8/gems/gettext-1.90.0/lib/gettext/rails.rb:278:in `render_file’
/vendor/rails/actionpack/lib/action_controller/base.rb:1107:in `render_for_file’
/vendor/rails/actionpack/lib/action_controller/base.rb:841:in `render_with_no_layout’

问题原因为ActionView::Base#file_exists?在rails2.1中已经被移走。

解决方法:
在config/initializers/ 下新建一个文件gettext.rb,内容如下:
module ActionView
  class Base
    delegate :file_exists?, :to => :finder unless respond_to?(:file_exists?)
  end
end

你可能感兴趣的:(Rails,Ruby)