Ok, I have 3 models, user
event
and participation
, and the associations between these are:
class Event < ActiveRecord::Base
belongs_to :user
has_many :users
has_many :participations, through: :participations
...
end
and
class User < ActiveRecord::Base
has_many :events
has_many :participations
has_many :event_participations, through: :participations, :source => :event
...
end
and
class Participation < ActiveRecord::Base
belongs_to :user
belongs_to :event
...
end
and in my routes i have like( I'm aware that nested resources more than one level are not advised, but i don't know any other way around it):
resources :user do
resources :events do
resources :participations
end
end
ok, until now on the event page, i can check if the current user is participating in that event or not, but i want to add a button to the event show page so if the user is not participating, it can do that easily, but i can't figure it out how to do that.
Thanks for your help.
Aucun commentaire:
Enregistrer un commentaire