combine two fields for slug in rails
I have used Slugged gem, and have it working fine in standard mode which is slugged on one name field.
Next thing I want to do is to combine two fields into the slug, example I have a link model that is linked to two item records. I want the link slu开发者_开发问答g to have the names of both the items. Example /link/item1name-and-item2name
is_sluggable :full_name def full_name "#{first_name} #{last_name}" end
you could use the :convertor
option and pass a method name or block
something like:
is_sluggable :convertor => :my_method
def my_method
"#{item1.name} and #{item2.name}"
end
精彩评论