Replace unless else with if else and fix undefined method error
This commit is contained in:
parent
067f61364d
commit
a09b04a865
1 changed files with 9 additions and 8 deletions
|
|
@ -45,14 +45,20 @@ class Ability
|
|||
# can view Commercials of confirmed Events
|
||||
can :show, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(state: 'confirmed').pluck(:id)
|
||||
can [:show, :create], User
|
||||
unless ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||
if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||
can [:new, :create], Registration do |registration|
|
||||
conference = registration.conference
|
||||
can_register?(conference, registration)
|
||||
end
|
||||
|
||||
else
|
||||
can :show, Registration do |registration|
|
||||
registration.new_record?
|
||||
end
|
||||
|
||||
can [:new, :create], Registration do |registration|
|
||||
conference = registration.conference
|
||||
can_register?(conference)
|
||||
can_register?(conference, registration)
|
||||
end
|
||||
|
||||
can :show, Event do |event|
|
||||
|
|
@ -63,11 +69,6 @@ class Ability
|
|||
event.program.cfp_open? && event.new_record?
|
||||
end
|
||||
|
||||
else
|
||||
can [:new, :create], Registration do |registration|
|
||||
conference = registration.conference
|
||||
can_register?(conference)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -244,7 +245,7 @@ class Ability
|
|||
end
|
||||
end
|
||||
|
||||
def can_register? conference
|
||||
def can_register? conference, registration
|
||||
conference.registration_open? &&
|
||||
registration.new_record? &&
|
||||
!conference.registration_limit_exceeded?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue