Questions tagged [friendly-id]

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.

The project on github

496 questions
4
votes
0 answers

Heroku Friendly_Id Gem undefined method slug

So Iv created a basic app on rails and uploaded it to heroku. Everything works perfectly on my local machine including the friendly_Id gem. Iv pushed my app to heroku and everything works fine, up until i try to post something where I get an…
Gurmukh Singh
  • 1,875
  • 3
  • 24
  • 62
4
votes
2 answers

Friendly ID slug does not contain the id

I want to have urls like this: http://domain.com/products/454-table-lamp So I use friendly_id like so: extend FriendlyId friendly_id :slug_candidates, use: :history def slug_candidates [ [:id, :title] ] end Now, since friendly id…
Besi
  • 22,579
  • 24
  • 131
  • 223
4
votes
1 answer

Switch locale on current page rails

i'm currently working on a project which has 2 different locals (nl/fr). We're facing this problem : How can I get the translated url for the current page when I display fr/nl button I'm currently working with friendly_id and globalize we've tried…
Thounder
  • 315
  • 2
  • 14
4
votes
1 answer

Language Specific Routes For Static Pages in Rails 3

Application using Rails 3.2.8 with below gems gem 'friendly_id', '~> 4.0' gem 'globalize3',"0.3.0" gem 'route_translator' In controller /app/controllers/home_controller.rb def static_pages # page url is unique and used for finding static pages. …
4
votes
3 answers

friendly-id: Undefined method slug for Movie

I downloaded the friendly_id gem in order to make my URLs more user friendly. To honor their instructions, I am asking this here instead of on GitHub. Here is my Show Method def show @movie = Movie.friendly.find(params[:id]) end This is in…
Johnson
  • 1,679
  • 1
  • 14
  • 21
4
votes
1 answer

Rails 4 Blog /:year/:month/:title with clean routing

In Rails 4 is there another cleaner way to achieve routes, such as: /blog/2014/8/blog-post-title /blog/2014/8 /blog/2014 /blog/2014/8/tags/tag-1,tag-2/page/4 /blog/new OR /blog_posts/new I've tried the following using FriendlyId (as well as…
TODOMyName
  • 43
  • 4
4
votes
2 answers

Friendly_id for fixtures (slugs)

I am using freindly_id in my application. I have setup a few fixtures in my application. I want to do integration testing on them. During the tests I need the friendly_id, but the DB records created from fixtures do not have the corresponding slugs…
Obaid
  • 41
  • 3
4
votes
2 answers

Friendly_id create slugs for a existing model

I have Locations models - countries/regions/cities which have in total 50k plus records. i have added the configuration to these models. Is there a way through the command line i can create the slugs for these models at one go instead of editing and…
Harsha M V
  • 54,075
  • 125
  • 354
  • 529
4
votes
1 answer

Why do you have to explicitly specify scope with friendly_id?

I'm using the friendly_id gem. I also have my routes nested: # config/routes.rb map.resources :users do |user| user.resources :events end So I have URLs like /users/nfm/events/birthday-2009. In my models, I want the event title to be scoped to…
nfm
  • 19,689
  • 15
  • 60
  • 90
3
votes
1 answer

friendly_id thowing error while creating a new user

I have a model User which is polymorphically associated with Person and Company model. I am using friendly_id to show permalinks for both Person and Company. Person has first_name attribute and I put the following in my model. extend…
Kumar Navneet
  • 81
  • 2
  • 5
3
votes
2 answers

friendly_id and real id

Is there any way to get the real id column from a model that is modified with friendly_id? I don`t want to make another db query for it, in performance reasons.
M2_
  • 217
  • 4
  • 14
3
votes
3 answers

Breadcrumbs list in ActiveAdmin shows wrong name when using friendly_id

I have a model named Company that has code. The column is used for friendly_id. class Company < ActiveRecord::Base extend FriendlyId friendly_id :code, use: :slugged end ActiveAdmin doesn't recognize friendly_id, so that I had to override…
ironsand
  • 14,329
  • 17
  • 83
  • 176
3
votes
1 answer

Understanding slug_candidates method in Rails model

I am trying to create pretty URLs in my Rails app. I could not understand what is happening inside the #slug_candidates method in the model. class News < ApplicationRecord friendly_id :slug_candidates, use: [:slugged, :finders, :history] def…
current_user
  • 1,172
  • 1
  • 16
  • 28
3
votes
1 answer

Rails + Friendly ID: Have some paths use the numerical ID

I have a Rails application that uses the friendly_id Gem. Using Friendly ID works well. However, there are some paths in the backoffice where I do not want to use the Friendly ID slug in the URI, as it is not possible to use the same scopes as in…
Qqwy
  • 5,214
  • 5
  • 42
  • 83
3
votes
2 answers

Rails friendly id with non-Latin characters

I have a model which I use its friendly id as slug: extend FriendlyId friendly_id :slug_candidates, :use => :scoped, :scope => :account def slug_candidates :title_and_sequence end def title_and_sequence slug = normalize_friendly_id(title) …
guyaloni
  • 4,972
  • 5
  • 52
  • 92
1 2
3
33 34