Help understanding ActiveResource

I'm trying to better understand ActiveResource in Rails 3.

I have this Object that extends ActiveResource::Base, and when I use the
collection_path, and pass an argument to it, the returned URL has that
argument as params in the URL instead of creating the URL like in the
docs.

For example. The docs say

Post.collection_path #=> /posts.xml
Comment.collection_path(:post_id => 5) #=> /posts/5/comments.xml

Here is what I'm getting

Post.collection_path => /posts.xml
Comment.collection_path(:post_id => 5) #=> /comments.xml?post_id=5

I'm using Rails 3.0.1.

Thanks

~Jeremy

Jeremy Woertink wrote in post #965832:

Post.collection_path #=> /posts.xml
Comment.collection_path(:post_id => 5) #=> /posts/5/comments.xml

Here is what I'm getting

Post.collection_path => /posts.xml
Comment.collection_path(:post_id => 5) #=> /comments.xml?post_id=5

Thanks

~Jeremy

Hi Jeremy

you are reading the doc which is for ActiveRecord::Base instance

but
you are experimenting with ActiveResource::Base instance

please read documentation for ActiveResource (not ActiveRecord)

Thani
Castlerock research Info

Sniper Abandon wrote in post #965916:

you are reading the doc which is for ActiveRecord::Base instance

but
you are experimenting with ActiveResource::Base instance

please read documentation for ActiveResource (not ActiveRecord)

Not true. The example shown in ActiveResource::Base is what the OP
referred to.

Here's the real issue. The example...

Post.collection_path #=> /posts.xml
Comment.collection_path(:post_id => 5) #=> /posts/5/comments.xml

...is showing that Comment is a nested resource of Post so therefore
need to match the nested resource definition in your routes.rb file...

resources :posts do
  resources :comments
end

http://guides.rubyonrails.org/routing.html#nested-resources