Friendly_id with two parameters?

I wonder if there is an easy way to use friendly_id and have two parameters instead of one, for example?

www.example.com/dateTitle/

date and name are two separate fields in my db.

+4
source share
2 answers

I know this question was made 2 years ago, but if it can help future readers, friendlyId gem now combines the "candidate" functionality, which can help with this.

class Post < ActiveRecord::Base extend FriendlyId friendly_id :slug_candidates, use: :slugged def slug_candidates [ [:created_at, :Title], ] end end 

More info at gem repo .

+10
source

Of course have!

Just define a model method that formats the string before it runs.

Refer to this example: https://gist.github.com/2650300

+7
source

Source: https://habr.com/ru/post/1411096/


All Articles