Class: Invitation

Inherits:
ApplicationRecord show all
Defined in:
app/models/invitation.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

aggregate_of, all_except, defaults, name_model_as, numbered, #save, #save_and_notify!, #save_and_notify_changes!, #update_and_notify!, update_or_create!

Class Method Details

.find_by_code(code) ⇒ Object



2
3
4
5
6
7
8
9
# File 'app/models/invitation.rb', line 2

def self.find_by_code(code)
  Invitation
    .where(code: code)
    .where(Invitation.arel_table[:expiration_date].gt(Time.now))
    .take!
rescue RangeError
  raise RecordNotFound.new('The invitation does not exist or it has expired')
end

.import_from_json!(json) ⇒ Object



11
12
13
# File 'app/models/invitation.rb', line 11

def self.import_from_json!(json)
  Invitation.create! json
end

Instance Method Details



19
20
21
# File 'app/models/invitation.rb', line 19

def navigable_name
  I18n.t(:invitation_for, course: course_name)
end

Returns:

  • (Boolean)


23
24
25
# File 'app/models/invitation.rb', line 23

def navigation_end?
  true
end

#organizationObject



15
16
17
# File 'app/models/invitation.rb', line 15

def organization
  Organization.find_by! name: course.to_mumukit_slug.organization
end

#to_paramObject



27
28
29
# File 'app/models/invitation.rb', line 27

def to_param
  code
end