move subscribe to its own controller, add authorization, test subscribe/unsubscribe
This commit is contained in:
parent
97bf86454e
commit
3be200abcc
7 changed files with 92 additions and 43 deletions
|
|
@ -129,6 +129,9 @@ class Ability
|
|||
def signed_in(user)
|
||||
guest # Inherits abilities of guest
|
||||
|
||||
# Can subscribe, unsubscribe to a conference
|
||||
can [:create, :destroy], Subscription, user_id: user.id
|
||||
|
||||
# Conference Registration
|
||||
can :manage, Registration, user_id: user.id
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@ class User < ActiveRecord::Base
|
|||
},
|
||||
presence: true
|
||||
|
||||
def subscribed? conference
|
||||
self.subscriptions.find_by(conference_id: conference.id).present?
|
||||
end
|
||||
|
||||
# Returns the ticket purchased ticket
|
||||
# ====Returns
|
||||
# * +TicketUser::ActiveRecord_Relation+ -> user
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue