Adding custom :new routes using Rails 3 routing -


In Rail 2, we can add custom new functions to resource routes, such as:

  map.resources: user,: new => {: Apply => : Get}}  

How can we get the same thing in Rail 3?

  Resources: Users receive: apply, but =>: new # does not work: get new: # applications also do not end the end  

Any thoughts?

You can use : path_names as the side routing guide :

  resources: user,: path_names = & gt; {: New = & gt; "Apply"}  

This will only replace the path to Apply , yet it will be routed for the new action I do not think the change is now clearly supported (which is probably a good thing).

If you want to keep your apply action, then you should:

  resources: user, except: => gt; ; : New tax collection is available: Apply end end  

but it leaves you thinking that it should only apply to verb to new name Not better for changing .


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -