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 remove specific words from a URL using friendly_id | ruby on rails

I am using friendly_id for my rails app and noticed it put in a slug, word-for-word. I was wondering if there was a way to parse the slug from containing non-SEO relevant words such as "and" and "for". I have tried some REGEX but I'm not even sure…
Jake
  • 1,086
  • 12
  • 38
0
votes
1 answer

Friendly_id PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer:

I try to use Friendly_id but I have an error just for one model. track model : class Track < ApplicationRecord extend FriendlyId friendly_id :track_name, use: :slugged has_many :pois poi model : class Poi < ApplicationRecord extend…
Ben
  • 660
  • 5
  • 25
0
votes
1 answer

uninitialized constant Post::FriendlyID

Update A solution was found while writing this question. Still posting the question in case someone else has the same issue. My solution was because of a typo. See bottom of this post and the posted answer for complete code. Original…
0
votes
2 answers

Search for slugs across all models using friendly_id models

I am using FriendlyId across a bunch of different model. For a particular use-case with usernames, I can't use FriendlyId but still want to make sure the username is not being used as a slug in any of those models. Currently, I have a .exists query…
geoboy
  • 1,172
  • 1
  • 11
  • 25
0
votes
1 answer

Rails route masking

I have a rails app where I have a userpage. Each userpage is a dashboard for a user showing his listings and his activities. I am also using a User model which is coming from devise so I can't use user/:id to refer to a user as that is used for…
0
votes
1 answer

Rails friendly_id gem; Could not find generator 'friendly_id'

I am running Rails 5.1.5.rc1 and Ruby 2.5.0. Just added the friendly_id gem (gem 'friendly_id', '~> 5.1.0') to my gemfile and ran bundle install. I then ran rails generate friendly_id Immediately I get the error "Could not find generator…
jacobrubyonrails
  • 147
  • 1
  • 10
0
votes
2 answers

Removing old friendly_id gem slug when updated

Scenerio: 1- User signs up with username elon_musk 2- Profile url is mywebsite.com/users/elon_musk 3- Elon edits his username to elonmusk 4- Now his profile url is mywebsite.com/users/elonmusk It is all good so far, but I noticed…
Designer
  • 1,061
  • 1
  • 12
  • 26
0
votes
1 answer

Rails 5 issue friendly_id search in db by name does not allow to delete or update?

this is my model User class User < ApplicationRecord extend FriendlyId friendly_id :name end the user name is not uniq. i want my url like this: http://localhost:3000/users/myname this is my controller: class UsersController <…
matQ
  • 597
  • 2
  • 13
  • 27
0
votes
1 answer

Rails - What's the best way to route duplicate slugs with a forward slash?

I'm using friendly_id 5.2. By default, it just appends a random UUID on the end for what would be duplicate slugs (post-60948cdd-d73c-4b77-9676-ecdf7727c396), but with the sequentially_slugged method you can just turn it back to how it worked in…
JackHasaKeyboard
  • 1,599
  • 1
  • 16
  • 29
0
votes
1 answer

Find resource by slug in nested resource in rails

I have following routes resources :shops do resources :categories end And when I visit this url: http://localhost:3000/shops/rabin-shop/categories I first want to find the shop by using slug 'rabin-shop', then I can filter the categories of…
0
votes
1 answer

why does friendly-id have add slug column on tabled and can't be found?

I'm have article table class CreateArticles < ActiveRecord::Migration[5.1] def change create_table :articles do |t| t.string :title t.text :body t.timestamps end end end followed friendly_id README 1). rails generate…
F___
  • 149
  • 3
  • 17
0
votes
1 answer

undefined method `find_by_friendly_id' with FriendlyId gem and Rails 5.1

I want to prevent selecting user with his id and that's why I am using this method which should work in this way, but instead I am getting this error: undefined method `find_by_friendly_id' ... This is the user model: include…
0
votes
1 answer

No route matches ... missing required keys

I have two controllers and models Projects and Schemas. Schemas belongs_to projects. Projects has_many schemas. I am looking for http://localhost:3000/projects/SLUG-PROJECT/schemas/SLUG-SCHEMA. Following is my SchemaController code: class…
0
votes
1 answer

Conditionally reset slug using friendly_id gem

My app assigns slugs in the usual way using the friendly_id gem: class Organization < ApplicationRecord extend FriendlyId friendly_id :name, use: :slugged strip_attributes end When a user changes the organization.name, by default the slug…
moveson
  • 5,103
  • 1
  • 15
  • 32
0
votes
2 answers

Ruby on Rails Article Load Rollback on show.html.erb

I can't understand why this is happening, seems that id of article is being queried even though friendly.id has been found. ID being found is "0" for any article that i click, even though the correct article_id (59) is found when associated with a…
doyz
  • 887
  • 2
  • 18
  • 43