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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 > > ~JeremyHi 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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.