Sunday 15 January 2012

ruby on rails - routing with non rest actions -


IM My administrator is having trouble creating a path for my non-restfull operation, here's my code:

Controller: Class Store Controller & lt; ApplicationController def toggle_store @ store = store.find (params [: store]) if @ store.available == correct @ store.update_attribute (available, incorrect) other @ store.update_attribute (available, true) end redirect_to @store end end

Route: Resources: Groups use resources: Stores members: Toggle_store end and end < P> But when I use the path in a link, I get this URL:

And I want something like this:

Any ideas?

Thanks:

Rake Route:

  toggle_store_group_store Posts / Groups /: group_id / stores /: id / Toggle_store (.format) Store # toggle_store   

link:

  & lt;% = link_to "toggle", toggle_store_group_stores_path (group, store) ,: method = & gt; : Post% & gt;    

OK I fixed it like this:

routes .rb: Resources: Groups use resources: store posts: toggle_store and end

Controller:

  Def toggle_store authorized! : Toggle, store @ store = store.find (params [: store_id]) if @ store.available == correct @ store.update_attribute (: available, wrong) else @ store.update_attribute (available, true) end redirect_to @ Group end   

link:

  <%> link to "to", toggle_store_group_store_path (group, store) ,: method = & gt; : Post% & gt;    

No comments:

Post a Comment