我再 routers 中写下如下的路由,然后 POST 地址 /weixin,出现错误 No route matches [POST] "/weixin"
scope :path => '/weixin', :via => :post do
match "/", :to => 'weixin#method_text', :constraints => lambda{|request| Nokogiri::XML(request.body.read).xpath('//MsgType').text == 'text'}
match "/", :to => 'weixin#method_image', :constraints => lambda{|request| Nokogiri::XML(request.body.read).xpath('//MsgType').text == 'image'}
match "/", :to => 'weixin#method_location', :constraints => lambda{|request| Nokogiri::XML(request.body.read).xpath('//MsgType').text == 'location'}
match "/", :to => 'weixin#method_event', :constraints => lambda{|request| Nokogiri::XML(request.body.read).xpath('//MsgType').text == 'event'}
end
但是我这样写是可以的
scope :path => '/weixin', :via => :post do
match "/", :to => 'weixin#method_event', :constraints => lambda{|request| Nokogiri::XML(request.body.read).xpath('//MsgType').text == 'event'}
end
不太懂是什么原因,求教各位