I have three (relevant) models specified as follows:
class User < ActiveRecord::Base
has_many :posts
has_many :comments
has_many :comments_received, :through => :posts, :source => :comments
end
class Post < ActiveRecord::Base
belongs_to :user
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :user
belongs_to :post
end
I would like to be able to link everything comments_receivedto userusing the route - let him talk about approving comment comments on all posts. (note that you can also get commentsdone user, but users cannot comment on their own posts, so commentsthrough a postthey are different from each other and mutually excluded). Logically this should work with:
map.resources :users, :has_many => [:posts, :comments, :comments_received]
That should give me routes
user_posts_path
user_comments_path
user_comments_received_path
The first two works, and the last not. I tried it without _to comments_receivedno avail. I am looking to get a url like
http://some_domain.com/users/123/comments_received
, , , . , :
map.resources :users do |user|
user.resources :comments
user.resources :posts, :has_many => :comments
end
URL :
http:
, , ?
? , comments, .
!
stephancom