I haven’t posted much recently as I’ve been very busy at work (more on that later) so I thought I would post another Rails tip.
## Model
class Person < ActiveRecord::Base
def to_s
self.title
end
end
# View
link_to person
# Output
<a href=\"http://foo.bar/person/1\">Zach Inglis</a>
View Pastie
Furthermore you could extend it like this:
## Model
class Person < ActiveRecord::Base
def to_s
self.title
end
def to_param
self.slug
end
end
# View
link_to person
# Output
<a href=\"http://foo.bar/person/zach-inglis\">Zach Inglis</a>
View pastie




