Craig,

ARes loads up associated objects just fine for me when using the
same :include syntax as you do. Are you using any recent version
Rails? If you are - then I believe the default format for ARes models
was recently changed from xml to json, so just check you Rails logs to
see which of your formats actually works. It might be that it is
format.json, and so you only have to add .to_json(:include
=> :players) call in there to get the associations working.

Regarding the second issue (you having /raids/players/1 instead of /
raids/1/players) - I believe you're misunderstanding how routes work,
and what collection/member DSL methods are. If you want to have a
route that works like /raids/:raid_id/players/:player_id - then
players belong to a (single) member of raids, and not to the whole
collection of raids. So you have to change your routes to something
like this:

resources :raids do
  member do
    get :players
  end
end

(note member instead of collection for nested route). Though, given
your last example, I think what you're really after is the nested
resource route - and in this case the following simple definition
should work for you:

resources :raids do
  resources :players
end

You can find more details and examples here:
http://guides.rubyonrails.org/routing.html#nested-resources

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to rails-oceania@googlegroups.com.
To unsubscribe from this group, send email to 
rails-oceania+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to