Class: Person

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/person.rb

Instance Method Summary collapse

Instance Method Details

#before_createObject



26
27
28
29
30
31
32
33
34
35
# File 'app/models/person.rb', line 26

def before_create
  # Let's generate a nice looking id
  self.id ||= new_id =
    name.gsub(/\[[\w-]*\]/, '').strip \
    .gsub(/\s/, '_').gsub(/[^\w]+/, '') \
    .gsub(/_+/, '_').gsub(/(^_|_$)/, '') if name

  i = 0
  self.id = "#{new_id}_#{i+=1}" while self.class.find_by_id self.id
end

#userObject

Convenience method, because User is as it was from the salted login plugin



22
23
24
# File 'app/models/person.rb', line 22

def user
	return User.(name)
end