Skip to content

Commit

Permalink
Merge branch 'rails2.0.2' of git@github.com:tablatom/hobo into writab…
Browse files Browse the repository at this point in the history
…le2.0.2
  • Loading branch information
James Garlick committed Jun 27, 2008
2 parents f62e7cd + 04500d8 commit c62782c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions hobo/lib/hobo/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,17 @@ def has_many_with_join_record_management(name, options={}, &b)
def to_url_path
"#{self.class.to_url_path}/#{to_param}" unless new_record?
end


def to_param
name_attr = self.class.name_attribute
if name_attr
readable = send(name_attr).to_s.downcase.gsub(/[^a-z0-9]+/, '-').gsub(/-+$/, '').gsub(/^-+$/, '').split('-')[0..5].join('-')
@to_param ||= "#{id}-#{readable}"
else
id
end
end


def with_acting_user(user)
Expand Down

0 comments on commit c62782c

Please sign in to comment.