I have a model Project which has_many excursions.
class Project < ActiveRecord::Base
has_many :excursions
def remove_user_from_excursion(excursion_id, current_user)
excursions.find(excursion_id).users.delete(current_user)
save!
end
end
then I have a model Excursions which has_and_belongs_to_many_users users.
class Excursion < ActiveRecord::Base
belongs_to :project
has_and_belongs_to_many :users
end
I would like to provide the functionality to remove a user from an excursion, I have tried calling the remove_user_from_excursion method on the Project model and it does not seem to work. The user remains as part of the excursions. What am I doing wrong?