I have two classes, InstructionalObject and Assets. They both have_many
of the other, implemented through a join table (so it’s like a habtm
without the habtm).
For the next version of our app, we’re refactoring to RESTful, and i’m
having trouble with my nested resources/routes. I tried this, in
routes.rb:
map.resources :assets do |assets|
assets.resources :instructional_objects
end
map.resources :instructional_objects do |instructional_objects|
instructional_objects.resources :assets
end
thinking that would let me do
instructional_objects/:id/assets
to get all the assets belonging to that instructional_object
and
assets/:id/instructional_objects
for vice-versa.
However, when i go to these urls i get all assets, and all instructional
objects respectively: in other words, these two routes seem to be
equivalent
“instructional_objects/:id/assets” and “assets”
and these two are equivalent:
“assets/:id/instructional_objects” and “instructional_objects”.
To make life more confusing for myself (initially at least) i’m also
using resource_this in my controllers. Looking in the log, it looks
like the right request (i think) is going through:
Processing AssetsController#index (for 127.0.0.1 at 2008-03-12 13:45:56)
[GET]
Session ID: 4ca8db0cc675a9dd71fc0ee96031f6ea
Parameters: {“instructional_object_id”=>“0”, “action”=>“index”,
“controller”=>“assets”}
Can anyone help, please?
max