Rails routes, using something other than model_id in resources route -


i have nested resources. here's example:

 resources :contests     resources :scoring_periods       resources :entries     end   end 

i'd have url looks following:

/contests/1/scoring_periods/10/entries/new 

the catch here /10/ in scoring_periods not scoringperiod#id. instead attribute named period_count in case. i'd able reference period_count in url instead of id system might have millions of ids later , it's not intuitive list there. actual period_count number, makes lot more sense users entering contest.

is there way munge resources entry in routes.rb in order allow me reference scoring_periods attribute other :scoring_period_id ?

something should work:

resources :contests   scope path: '/scoring_periods/:period_count/'     resources :entries   end end 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -