FriendlyId is the "Swiss Army bulldozer" of slugging and permalink plugins for Ruby on Rails. It allows you to create pretty URL's and work with human-friendly strings as if they were numeric ids for Active Record models.
Questions tagged [friendly-id]
496 questions
6
votes
2 answers
Friendly Id Custom Slug
I have a Post model
#post.rb
extend FriendlyId
friendly_id :slug_candidates, use: [:slugged, :history]
I'm trying to customize the url for each post like so
#post.rb
def slug_candidates
"#tutorial-#{user.display_name}-#{title}"
end
Friendly…

Zonblar
- 107
- 5
6
votes
1 answer
Friendly ID and Rails Engines
I followed the steps to get friendly_id working in the rails engine - which are posted here on github and it seems that when I do the following:
s.add_dependency 'friendly_id', '~> 5.0.0'
in the engine.gemspec file and then do:
bundle install #=>…

user3379926
- 3,855
- 6
- 24
- 42
6
votes
1 answer
Rails FriendlyId and normalize_friendly_id
Trying to get my app running the FriendlyId gem (version 4.0.1)
I think I'm doing this in the wrong order, but I want to strip out apostrophes before my friendly_id slug is generated when creating a new record. But I think the method…

jordan.baucke
- 4,308
- 10
- 54
- 77
5
votes
1 answer
friendly_id generate slug with ID
I am trying to use the friendly_id gem to generate a slug in the format of "#{id}-#{title}"
It looks like friendly_id uses before_save, and won't have access to the ID attribute.
Is there a work around for this ?
#…

Andrew Cetinic
- 2,805
- 29
- 44
5
votes
3 answers
Friendly_Id and Reserved Words -- How can i replace the reserved word?
Here is an example of what causes the error:
ruby-1.9.2-p290 :004 > Post.new(title: "new").save!
(0.3ms) BEGIN
post Load (0.3ms) SELECT `posts`.* FROM `posts` WHERE (`slug` = 'new' OR `slug` LIKE 'new--%') ORDER BY LENGTH(`slug`) DESC, `slug`…

Mario Zigliotto
- 8,315
- 7
- 52
- 71
5
votes
2 answers
Friendly_id change slug on Record Update
Am i doing something wrong ? on Record update, slug is not being updated.
class Company < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: [:slugged, :finders]
def should_generate_new_friendly_id?
true
end
I'm using:
…

kashif
- 1,097
- 4
- 17
- 32
5
votes
2 answers
How can I use friendly ID in Rails like mysite.com/[USERNAME]
How can I use friendly URLs on my Rails application ?
All I need is to make available the following url format
mysite.com/company1
mysite.com/user123
mysite.com/user1234
mysite.com/newton.garcia
mysite.com/company-name
Can anyone help ?

newx
- 595
- 7
- 16
5
votes
3 answers
friendly_id and acts_as_paranoid creating duplicate slugs
I'm current using acts_as_paranoid and friendly_id (5.0.1) on a model and when I destroy a model and try to create a new one that will generate the same slug I get:
ERROR: duplicate key value violates unique constraint "index_papers_on_slug"
I…

Lindsey B
- 556
- 3
- 15
5
votes
4 answers
Friendly_id: slug_candidates not naming slug properly
I have the following in my model:
class Dispenser < ActiveRecord::Base
extend FriendlyId
friendly_id :slug_candidates, use: :slugged
def slug_candidates
[
:full_name,
[:full_name, :id]
]
end
end
This is generating…

Abram
- 39,950
- 26
- 134
- 184
5
votes
0 answers
Rails: friendly_id & globalize not checking translation tables for conflicts
I'm using friendly_id (4.10.1) and globalize (3.0.0) in my Rails 3.2.14 app:
# globalize3
translates :title, :slug
# friendly_id
extend FriendlyId
friendly_id :title, use: [:slugged, :globalize]
When I save my inputs, friendly_id checks for…

Railsana
- 1,813
- 2
- 21
- 30
5
votes
2 answers
FriendlyID Korean slugs
When I add article in Korean language with title e.g.: 신품
FriendlyID gem creates blank slug and url is like /8 ... so this is ID. Look at this link: http://www.srecipe.kr.com/articles/8
Other languages work.
How can I get url which is mapped to…

Richard Lapiš
- 63
- 5
5
votes
1 answer
How to make friendly id case insensitive?
How can i replicate twitter usernames in URL cas insensitive:
www.site.com/users/My_Name
www.site.com/users/my_NAMe
www.site.com/users/MY_NAME
And that all these URL's, opens user page when he has username saved as "MY_Name" or etc.
And…

liutis
- 425
- 5
- 12
5
votes
1 answer
Friendly_id using value from belongs_to association
I have the following models:
class User < ActiveRecord::Base
extend FriendlyId
friendly_id :first_name, :use => :slugged
has_one :professor
after_create :create_professor
def create_professor
self.professor = Professor.create
…

Nobita
- 23,519
- 11
- 58
- 87
5
votes
2 answers
Friendly_id with two parameters?
I wonder if there's an easy way to use friendly_id and have two parameters instead of one, like this?
www.example.com/dateTitle/
date and title are two separate fields in my db.

Philip
- 6,827
- 13
- 75
- 104
4
votes
1 answer
Friendly_id gem using UUIDs despite being overrriden
I have a model, and in accordance with the friendly_id gem it looks like this:
class FinancialYear < ApplicationRecord
extend FriendlyId
friendly_id :slug_candidates, use: :slugged
def slug_candidates
[
:end_year,
…

Ash
- 24,276
- 34
- 107
- 152