Custom method routes in a nested has_one resource?

I’m struggling with the syntax for some routes - can anyone set me

a lesson has_one plan.
lesson has a bunch of custom methods (this is all fine)
plan needs some custom methods as well - i have these set up in a
non-nested way, eg
rather than, as it should be,


My regular actions all work in a nice, nested way:

/lessons/23/plan [GET]
goes to the show action. It’s just the custom actions i can’t work out

  • where do i put them in routes.rb? this is what i have already for
    lessons and plans:

map.resources :lessons, :has_one => [:plan], :member => { :preview =>
:get, :detail => :get, :download => :get, :online_xml => :get,
:offline_xml => :get, :remove_asset => :get, :delete_missing_elements =>
:post, :update_asset_positions => :get, :scorm_download => :get,
:add_non_interactive_activity => :post }

map.resources :plans, :has_many => [:schedule_columns,
:schedule_entries], :member => {:add_learning_objective => :post,
:plan_pdf => :get}

It never makes sense to call a plan outside of the context of a lesson
so it’s fine to make plan a totally nested resource: just as a has_one
rather than has_many.


Actually i think i figured it out - this seems to work ok:

map.resources :lessons, :member => { :preview => :get, :detail => :get,
:download => :get, :online_xml =>
:offline_xml => :get, :remove_asset
=> :get,
:delete_missing_elements => :post,
:update_asset_positions => :get,
:scorm_download => :get,
:add_non_interactive_activity =>
} do |lessons|
lessons.resource :plan, :has_many => [:schedule_columns,
:member => {:add_learning_objective => :post,
:plan_pdf => :get}

seems kind of obvious now :slight_smile: