Changing the URL if in nested resources

I have a nested restful resource working

map.resources :works do |work|
work.resources :work_sections

producing a url like:

I’d like to do two things with the URL, but am not sure where to start.

  1. I’d like to restrict the work_section from displaying if the work_id
    isn’t legit.
    Right now /works/2/work_sections/1 will pull up work_section_id 1 even
    if it
    is associated with work_id 1 (contrary to the url)

  2. Make it so that the work_section number in the URL is the :position
    opposed to :id) for the work_section which is an acts_as_list child of
    I want to avoid ending up with a url like:

I’m pretty sure accomplishing #2 will include my want for #1.

Is there an example or particular concept I need to look to research how
do this type of routing?

Rich Vázquez, CISSP, CISA

Check that in your controller code, make sure you use

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs