Add confirmed sponsors
This commit is contained in:
parent
b770f9bd4d
commit
792a7fed1c
10 changed files with 162 additions and 65 deletions
|
|
@ -1,4 +1,6 @@
|
|||
class Sponsor < ActiveRecord::Base
|
||||
include ActiveRecord::Transitions
|
||||
|
||||
belongs_to :sponsorship_level
|
||||
belongs_to :conference
|
||||
|
||||
|
|
@ -10,4 +12,25 @@ class Sponsor < ActiveRecord::Base
|
|||
mount_uploader :picture, PictureUploader, mount_on: :logo_file_name
|
||||
|
||||
validates :name, :website_url, :sponsorship_level, presence: true
|
||||
|
||||
scope :confirmed, -> { where(state: 'confirmed') }
|
||||
scope :unconfirmed, -> { where(state: 'uncofirmed') }
|
||||
|
||||
state_machine initial: :uncofirmed do
|
||||
state :uncofirmed
|
||||
state :confirmed
|
||||
|
||||
|
||||
event :confirm do
|
||||
transitions to: :confirmed, from: [:uncofirmed]
|
||||
end
|
||||
|
||||
event :cancel do
|
||||
transitions to: :uncofirmed, from: [:confirmed]
|
||||
end
|
||||
end
|
||||
|
||||
def transition_possible?(transition)
|
||||
self.class.state_machine.events_for(current_state).include?(transition)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue