我有一个 Rails 应用程序,Users
可以在其中创建Programs
和其他尚未到来的东西,我们会说Plans
(假设地)。
Users
还可以like
Programs
和Plans
。(就像是多态的)
我试图找出路线,以便我可以看到Programs
aUser
创建的所有东西 a User
likes
,或者只是Programs
或只是Plans
a User
likes
。我有这些路线,但这似乎不对。
resources :users, :only => [:index,:show] do
resources :programs, :only => [:index]
resources :likes, :only => [:index] do
resources :programs, :only => [:index]
end
end
该路由需要programs
一个user
likes
URL,例如:users/user_id/likes/like_id/program。
如何创建一个 URL,例如:users/user_id/likes/programs 并获取所有喜欢的程序。
I am using the Socialization Gem which has a method for "likeables_relation(Class)" which returns a relation of whatever class is requested. I just need help with the routing.