rest - Proper Routing in Rails for a diverse set of tools -
i trying clean routes , have situation not sure with:
i have number of tools & reports spread across variety of controllers basicially collections revolve around 2 parameters: divisions , term.
i wanted this:
resources :divisions resources :terms scope "/tools" #something redirect controller "carriers" , action "carrier_distribution" #something redirect controller "courses" , action "secour monitor" end end end
most of resources interested in nested within division.
it clean & helpful have url this:
/divisions/1/terms/1/tools/carrier_distribution
i have option make "tools" controller kick stuff off. not sure appropriate (like if should stick passing term parameter).
thanks!
personally i'd go toolscontroller, , map in routes:
map.connect "/divisions/:division_id/terms/:term_id/tools/:action", :controller => "tools"
then toolscontroller can access params:
class toolscontroller < applicationcontroller def report1 render :text => "hello report1, division[#{params[:division_id]}] term [#{params[:term_id]}]" end def report2 render :text => "hello report2, division[#{params[:division_id]}] term [#{params[:term_id]}]" end end
Comments
Post a Comment