开发者

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

开发者 https://www.devze.com 2023-01-16 04:08 出处:网络
I\'ve placed the file rack_app.rb with simple Rack application in the lib directory: class RackApp def cal开发者_JAVA百科l env

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

精彩评论

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