RESTful Routes help in Rails 3 -
i'm using rails 3, devise , mongoid.
i believe can accomplish need using restful routes not sure how it. let me explain have , trying do.
let's have 2 controllers - user , simpleform.
the simpleform public facing form (no authentication required) when submitted shows in user's account (when login).
i have multipul users on system , each 1 see form submissions that's specific them.
so question is, how public facing form submit specific user's account?
as of route fill out new form looks "site.com/simpleform/new". think can use routes make "site.com/simpleform/user_id/new" or "site.com/user_id/simpleform/new". either variation work think. when form submitted in public application knows user associate because of user_id in url.
i think logic works , restful routes can make happen, i'm not sure how it.
each user resource has 1 associated simpleform resource.
so think route like:
resources :users resource :simpleform end
and routes like:
user_simpleform post /users/:user_id/simpleform(.:format) {:action=>"create", :controller=>"simpleforms"} new_user_simpleform /users/:user_id/simpleform/new(.:format) {:action=>"new", :controller=>"simpleforms"} edit_user_simpleform /users/:user_id/simpleform/edit(.:format) {:action=>"edit", :controller=>"simpleforms"} /users/:user_id/simpleform(.:format) {:action=>"show", :controller=>"simpleforms"} put /users/:user_id/simpleform(.:format) {:action=>"update", :controller=>"simpleforms"} delete /users/:user_id/simpleform(.:format) {:action=>"destroy", :controller=>"simpleforms"} users /users(.:format) {:action=>"index", :controller=>"users"} post /users(.:format) {:action=>"create", :controller=>"users"} new_user /users/new(.:format) {:action=>"new", :controller=>"users"} edit_user /users/:id/edit(.:format) {:action=>"edit", :controller=>"users"} user /users/:id(.:format) {:action=>"show", :controller=>"users"} put /users/:id(.:format) {:action=>"update", :controller=>"users"} delete /users/:id(.:format) {:action=>"destroy", :controller=>"users"}
Comments
Post a Comment