Replace unless else with if else and fix undefined method error

This commit is contained in:
Arun Kumar 2016-08-09 22:20:56 +05:30
parent 067f61364d
commit a09b04a865
No known key found for this signature in database
GPG key ID: 6C40CA6462DEA424

View file

@ -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?