Re: Drying up Code

First, make a method in each of those models called ‘title_for_links’,
which returns the appropriate bit of text. That’ll standardise all of
those different method calls.

Then you could have something like:

def link_to_object(object)
link_to(object.title_for_links, :controller =>, action => :show, :id =>

assuming that the appropriate controller is always a lowercase version
of the object’s class name.


I like this approach. Simple and elegant. Thanks.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs