开发者

Why do I need to define a action in routes manually sometimes, and sometimes not?

Suppose i have indicated that network is a resource. I am adding a new action, say "submit_question_for_network" to the controller.

However, after I added the action to the controller, it does not work

# does not work
/network/submit_question_for_network  

# need to add to :collection
map.reso开发者_如何学JAVAurces :network,  :collection => {:submit_question_for_network => :post,:submit_new_or_join=>:post}   

However, i clearly remember that it works without needing to do anything sometimes. What is going on?

# it is trying to do "show", instead of calling the action
Processing NetworkController#show (for 127.0.0.1 at 2010-09-09 00:07:42) [GET]
  Parameters: {"id"=>"v4test"}


You've defined the two collection routes as post requests, however you're making a get request.

If you want to make a get request then redefine the route as so. If on the other hand you want to post a form then add :method => :post to the form helper method.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜