Module: HasFriendlyName::InstanceMethods
- Defined in:
- lib/has_friendly_name.rb
Instance Method Summary collapse
Instance Method Details
#generate_friendly_name ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/has_friendly_name.rb', line 40 def generate_friendly_name self.friendly_name = send(self.[:from].to_s.to_sym).to_friendly(self.) if self.[:unique] checkmodel=self.class.find(:first, :conditions => "friendly_name='#{self.friendly_name}'") if checkmodel and checkmodel!=self self.friendly_name+='-'+(self.class.count+1).to_s end end self.friendly_name end |