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
0
votes
1 answer
Rails: friendly_id slug relationship
I want to create a slug for my model which depends on a column of a related model. Is that possible?
Here is what I've thought:
# Example::User class
extend FriendlyId
friendly_id user.username, use: :slugged
belongs_to :user, class_name:…

heroxav
- 1,387
- 1
- 22
- 65
0
votes
0 answers
Friendly_id should generate same slug for inherited STI table
Friendly_id should generate same slug for inherited STI table.
I have a report model and a demo_report model which is inherited from report model, first a slug is generated for report using friendly_id. This is good
e.g. test-report
But when same…

Sonalkumar sute
- 2,565
- 2
- 17
- 27
0
votes
1 answer
Rails 5.0.1 - Friendly_id gem - included active concern module before_create or before_save
I have created this module:
app/models/concerns/sluggable.rb
module Sluggable
extend ActiveSupport::Concern
included do
before_create :set_slug
end
def set_slug
if self.slug.nil?
puts 'adding slug'
self.slug =…

rmcsharry
- 5,363
- 6
- 65
- 108
0
votes
1 answer
Using Friendly id to generate meaningful urls for similar names with different slug values- Rails 4
I have already setup Friendly Id following all the instructions from the Home page.
In short,i have added the module and slug column in my Place model table.
in my place.rb
extend FriendlyId
friendly_id :name, use: [:slugged, :finders,…

Milind
- 4,535
- 2
- 26
- 58
0
votes
1 answer
How to use friendly_id in where case with Rails?
I have two models: BigCategory and SmallCategory.
class BigCategory < ApplicationRecord
extend FriendlyId
friendly_id :name, use: :slugged
has_many :small_categories, dependent: :destroy
end
class SmallCategory < ApplicationRecord
extend…

s_zhang
- 847
- 2
- 8
- 16
0
votes
2 answers
Error using Friendly_Id with Rails on names ending with period
I have a rails model Company and want to have pretty urls on it instead of the default id (for seo and security reasons). For most of the cases it works. I've noticed on Company names ending with a period, I receive an error like the one below:
No…

Coder_Nick
- 781
- 1
- 8
- 25
0
votes
1 answer
acts_as_followers and friendly_id gems not finding id
Im using the acts_as_follower gem and friendly_id gem.
Iv set up acts_as_follower and everything is working as it should, I am able to follow Profiles as required. But now I have added the friendly_id gem to show profiles urls as profile/myname…

Gurmukh Singh
- 1,875
- 3
- 24
- 62
0
votes
1 answer
friendly_id on belongs_to model
I have a devise User model and a Profile model which belongs_to the User
class Profile < ApplicationRecord
belongs_to :user
end
The User model has a added column called name which stores the users name.
Im using friendly_id gem and want to…

Gurmukh Singh
- 1,875
- 3
- 24
- 62
0
votes
3 answers
FriendlyID for child
I have a Project model that belongs to a User. A User has_many Projects. I have setup FriendlyID according to the gem instructions for User model, however it is not working in this scenario.
<%= link_to gravatar_for(project.user, size: 50),…

user3180
- 1,369
- 1
- 21
- 38
0
votes
1 answer
Slug generated having two hyphens at the end in rails 3.2 using friendly id?
I am using friendly_id 4.0.10.1 gem for generating slug. I am using two columns to generate slug: first_name and last_name.
The last_name value can be empty. The problem arises in these cases:
first_name last_name slug
1. Arun Kumar …

Sahil
- 3,338
- 1
- 21
- 43
0
votes
1 answer
Generating slug for users in a table with 1 million users in a short time without affecting db performance in Rails?
I want to add a column to my users table and generate slug for all of them. The problem is I have over 1 million users in my DB.
I have seen various blogs explaining different methods but I do not want to take risk by doing it in my production DB.…

Sahil
- 3,338
- 1
- 21
- 43
0
votes
1 answer
Missing attribute: slug, when using friendly_id in Rails
I'm using friendly_id to generate sensible URLs for a chain of hairdressing salons.
However, I get this error on the home page, where I have links to some of the salons:
ActiveModel::MissingAttributeError in Pages#home
missing attribute: slug
The…

memius
- 4,045
- 5
- 26
- 25
0
votes
2 answers
Friendly_id name not displaying in url
I have added the friendly_id gem to my application. The name attribute is not replacing the index in the URL.
Gem
gem 'friendly_id', '~> 5.1.0'
Migration
rails g migration add_slug_to_items slug:string
Migration File
class AddSlugToItems <…

Ctpelnar1988
- 1,235
- 3
- 15
- 38
0
votes
0 answers
Rails Friendly_ID Multiple model creation with slug on same field failing
I am running a Rails 5 application which has 2 models - a User and a Provider. I am using multiple table inheritance to show that each Provider "is a" User (via the active_record-acts_as gem). So, in effect, creating a Provider with the related…

mindseyeblind
- 119
- 10
0
votes
0 answers
Build vanity urls with variables stored in a different table from the model
I am trying to build vanity urls with FriendlyId gem for a specific model Teacher to display
www.mysite.com/teachers/{first_name}-{last_name}
instead of
wwww.mysite.com/teachers/{id}
The problem that I encounter is that the information on the…

user6877257
- 45
- 1
- 4