osem-fcy/app/models/subscription.rb
Dimitris 2bf7e4bbd3 Fix user already subscribed exception
Prevent excpetion at user subscription when already is subscribed to a conference and add hanling to the similar unsubscribe event.

remove double validation at app/models/subscription.rb

update subscription_controller_spec
2017-07-23 17:07:28 +03:00

8 lines
287 B
Ruby

class Subscription < ActiveRecord::Base
belongs_to :conference
belongs_to :user
has_paper_trail on: %i(create destroy), ignore: [:updated_at], meta: { conference_id: :conference_id }
validates :user_id, uniqueness: { scope: :conference_id, message: 'already subscribed!' }
end