Class: Person
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Person
- Defined in:
- app/models/person.rb
Instance Method Summary collapse
- #before_create ⇒ Object
-
#user ⇒ Object
Convenience method, because User is as it was from the salted login plugin.
Instance Method Details
#before_create ⇒ Object
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 |
#user ⇒ Object
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.find_by_login(name) end |