Hi,
I have a Place model that has both 'city_name' and 'name' as attributes. I would like to define a custom method that finds the place whose name matches the city_name for another place eg.
Place.name = "foo"
Place.city_name = "baz"
then Place.find_city gives the record where Place.name = "baz". At the moment I've got something along the lines of:
def find_city
Place.find_by_name("this.place.city_name")
end
View:
<%= link_to "#{@place.city_name}", place_path(@place.find_city) %>
This code currently doesn't throw up any errors, but the link simply returns the current place record. Is this approach possible, and if so, what would be the best way to go about doing it? Thanks in advance!