class EditorRequest

editor would like to become an editor for person. Sent in an email with link keyed by token. Sends email with link after_create. See EditorRequestMailer.

Public Instance Methods

destroy_duplicates() click to toggle source
# File app/models/editor_request.rb, line 32
def destroy_duplicates
  EditorRequest.destroy_all :person_id => person_id, :editor_id => editor_id
end
grant!() click to toggle source

Make editor an editor of person

# File app/models/editor_request.rb, line 41
def grant!
  unless person.editors.include?(editor)
    person.editors << editor
    EditorRequestMailer.notification(self).deliver
  end
  destroy
end
send_email() click to toggle source
# File app/models/editor_request.rb, line 36
def send_email
  EditorRequestMailer.editor_request(self).deliver
end
set_email() click to toggle source
# File app/models/editor_request.rb, line 20
def set_email
  self.email = person.try(:email)
end
set_expires_at() click to toggle source
# File app/models/editor_request.rb, line 24
def set_expires_at
  self.expires_at = 1.week.from_now
end
set_token() click to toggle source
# File app/models/editor_request.rb, line 28
def set_token
  self.token = Authlogic::Random.friendly_token
end