开发者

Getting Uninitialized Constant when trying to add a route for Rack application in Rails 3

Trying to add a route for Rack class as follows:

  match '/sms' => MsgReceiver

the Rack class is:

# /lib/msg_receiver.rb
class MsgReceiver

  def self.call(env)
    [200, {}, "test"]
    # render
  end
end

The error I'm getting:

uninitialized constant MsgReceiver (NameError)

Why am I getting the error, Do I have to define MsgReceiver any开发者_如何学编程where?


Looking at http://yehudakatz.com/2009/12/26/the-rails-3-router-rack-it-up/, it appears that you need...

match '/sms', :to => MsgReceiver

Based on the error message you're getting, however, I'm not sure if this will actually resolve the problem. Perhaps, you also need to add require 'msg_receiver' at the top of your routes file?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜