开发者

Rails 3 does not see my class in "lib" directory

I've placed the file rack_app.rb with simple Rack application in the lib directory:

class RackApp
  def cal开发者_JAVA百科l env
    [200, {}, 'Hello']
  end
end

Then I've added this route:

match 'rack' => RackApp

And when I try to launch the rails server I get the following error:

config/routes.rb:65: uninitialized constant RackApp (NameError)


Rails 3 has no more autoloading by default. So you need require your file

require 'lib/rack_app.rb'

Or come back the autoloading in application.rb

config.autoload_paths += %W( #{config.root}/lib )


Include require 'email_format_validator' in the model.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜