Ruby on rails 铁路定制路线问题

Ruby on rails 铁路定制路线问题,ruby-on-rails,url-routing,Ruby On Rails,Url Routing,我有一个应用程序,它有一个用户和一个项目模型。这两个模型之间存在以下关系: USER has_many :authorships , :foreign_key => :author_id has_many :moderatorships, :foreign_key => :moderator_id has_many :authored_projects, :through => :authorships, :class_name => 'Project' has_many

我有一个应用程序,它有一个用户和一个项目模型。这两个模型之间存在以下关系:

USER
has_many :authorships , :foreign_key => :author_id
has_many :moderatorships, :foreign_key => :moderator_id
has_many :authored_projects, :through => :authorships, :class_name => 'Project'
has_many :moderated_projects, :through => :moderatorships, :class_name => 'Project'
我希望有一个路径是/users/id/favorite\u projects和/users/id/mediated\u projects。我的routes.rb中有以下内容

map.resources :users,:has_many => [:authored_projects, :moderatored_projects], :shallow => true, :collection => {:logins => :get}
但是当我跑耙路的时候

user_authored_projects GET    /users/:user_id/authored_projects(.:format)        {:controller=>"authored_projects", :action=>"index"}

但是,我并没有一个真正的作者项目控制器。我怎样才能做到这一点呢?

我想你应该在你的路线上做到这一点:

map.resources :users do |users|
  users.resources :authored_projects, :controller => :projects
  users.resources :moderated_projects, :controller => :projects
end
但我想你还想做些别的事情,比如:

map.resources :users, :member => [:authored_projects, :moderated_projects]

然后在
用户控制器中创建操作
编写的\u项目
主持的\u项目
。我真的不想创建另一个控制器。我已经有了Projects控制器,在模型关系中我指定“authored_Projects”实际上是Projects。我希望能够在routes中的:has_many=>[]选项中指定。