I have the following in my routes.rb
map.resources :novels do |novel|
novel.resources :chapters
end
With the above defined route, I can access the chapters by using xxxxx.com/novels/:id/chapters/:id
.
But this is not what I want, the Chapter model has another field called number (which corresponds to chapter number). I want to access each chapter through an URL which is something like
xxxx.com/novels/:novel_id/chapters/:chapter_number
. How can I accomplish this without explicitly defining a named route?
Right now I m doing this by using the following named route defined ABOVE map.resources :novels
map.chapter_no novels/:novel_id/chapters/:chapter_no , :controller => chapters , :action => show
Thanks.