I'm using the friendly_id plugin to generate SEO-friendly URLS for some of my models.
Currently, I have a model with two attributes: name and display_name.
Essentially, display_name is preferred, but if it is blank, the model reverts to name. Friendly_id needs a field to base the URL off of:
Class Market < ActiveRecord::Base
has_friendly_id :name
end
How can I implement something that looks (logically) like this:
Class Market < ActiveRecord::Base
if self.display_name
has_friendly_id :display_name
else
has_friendly_id :name
end
end
Thanks!