IM My administrator is having trouble creating a path for my non-restfull operation, here's my code:
Controller: Route: And I want something like this: Any ideas? Thanks: Rake Route: link: OK I fixed it like this: routes .rb: Controller: link: 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
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:
toggle_store_group_store Posts / Groups /: group_id / stores /: id / Toggle_store (.format) Store # toggle_store
& lt;% = link_to "toggle", toggle_store_group_stores_path (group, store) ,: method = & gt; : Post% & gt;
Resources: Groups use resources: store posts: toggle_store and end
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 to "to", toggle_store_group_store_path (group, store) ,: method = & gt; : Post% & gt;
No comments:
Post a Comment