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
0
votes
1 answer

how to fix undefined method `find_by_friendly_id'

I'm trying this Opportunity.find_by_friendly_id(params[:id]) inside a rails application with friendly_id configured. I get undefined method `find_by_friendly_id' for # Did you mean? find_by_sql Interestingly, this…
american-ninja-warrior
  • 7,397
  • 11
  • 46
  • 80
0
votes
2 answers

Friendl_id record not found

I just add friendly_id to beautify my urls. i get an error Couldn't find User with 'id'={:id=>"foo"} Here is my setup User.rb class User < ApplicationRecord extend FriendlyId friendly_id :last_name, use: %i[slugged…
Che
  • 112
  • 9
0
votes
0 answers

products of categories or categories of product listing

class Product < ApplicationRecord extend FriendlyId translates :name, :slug, :description friendly_id :slug_candidates, use: :globalize globalize_accessors :locales => [:tr, :en, :ar], :attributes => [:name, :slug, :description] …
0
votes
0 answers

Friendly id & Globalize gem handling with locale

I have set up friendly id and globalize gem. I am also using 2 locales, :es :en So I can create url like /search/en/spain. On main page for :en, the url becomes /search/en/spain and for :es it becomes /search/es/espana. When I visit this page and…
Shalafister's
  • 761
  • 1
  • 7
  • 34
0
votes
1 answer

why do i get NoMethodError?

I want my trade page to show a list of every Item that a user has added to their cart, and I'm having trouble understanding why this implementation is giving me a NoMethodError So in the #show action of my TradesController I have a trade_ids…
calyxofheld
  • 1,538
  • 3
  • 24
  • 62
0
votes
2 answers

Friendly_id still showing user id in the url

I am trying to use the Friendly_id gem and it works for user edit but not user show page. On the user show page it still uses the user id instead of the user_name which is the slug. I am not sure what my mistake is thank you for all the…
jrocc
  • 1,274
  • 2
  • 18
  • 48
0
votes
1 answer

Friendly_id User or Profile model

I have User(has_one :profile) model linked to a Profile(belongs_to :user) model. I will use username to slug profile url, the friendly shoud be implemented in User or Profile model? Thank you!
Adolfo
  • 131
  • 1
  • 3
  • 10
0
votes
3 answers

friendly_id url are not applying on pagination.

I am implementing friendly_id on a existing source code. The scenario is like this. There are category names on the home page. When user clicks on any one of these Categories link, it takes them to a page when it has products under that category.…
user3576036
  • 1,335
  • 2
  • 23
  • 51
0
votes
2 answers

How to redirect old urls to new friendly_id generated urls in rails app?

I prettified my urls using friendy_id. My old url used look like below: localhost:3000/search?category_id=208 Now it looks like this: localhost:3000/search?category_id=metal-processing-and-machine-tool My controller is this: def…
user3576036
  • 1,335
  • 2
  • 23
  • 51
0
votes
1 answer

FriendlyID with globalize

My Post model uses translates method from globalize gem and friendly_id to gerenate more user friendly urls. When I create my post in my native language it gets added. Accessing it after switching to en locale makes it fallback for the native…
mdmb
  • 4,833
  • 7
  • 42
  • 90
0
votes
1 answer

Friendly_ID url inside a model

I am using Rails with React in my app, and I wanted to pass url for Post model in as_json method. It has been working correctly with this method found on SO, where I pass the locale and the id (or…
mdmb
  • 4,833
  • 7
  • 42
  • 90
0
votes
2 answers

Old urls are still working after implementing friendly_id on rails app. How can I stop them and redirect to 404?

I implemented friendly_id on my rails app. Earlier when clicked on a link the url used to look like below: https://example.com/search?category_id=228 After implementing friendly_id when the link was clicked it started to give url as…
user3576036
  • 1,335
  • 2
  • 23
  • 51
0
votes
1 answer

FriendlyId redirecting to the basket instead or correct links

I have just installed FriendlyID to change the urls of my site. I have set this up for the categories although the links change as they should do when I click on them the url changes to basket/(correct-product). It's really bugging and I have been…
Walsh259
  • 29
  • 7
0
votes
2 answers

using friendly id with includes and where

I was using this query to fetch a property with nested resources @property=Property.includes(rooms: [:photos]).where(id: params[:id]).first The above works. But now I want to use friendly_id. So I tried @property=Property.includes(rooms:…
Abhilash
  • 2,864
  • 3
  • 33
  • 67
0
votes
1 answer

How to avoid FriendlyId creating a different slug if current already exists

I'm using FriendlyId gem on Ruby on Rails 5. Is there any way to stop FriendlyId to create a different slug if the current one has already been taken? I'd like the user to have full control over the slug.
a.barbieri
  • 2,398
  • 3
  • 30
  • 58