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

Rails - FriendlyId and Conditions

I have a model posts, which belongs_to category (which uses friendly_id). Now i want to list all Posts in an Category. To get the index page i want to use a link like: http://mysite/posts/category/_category_slug_, for that i made the following…
Marcus
  • 1
  • 2
0
votes
1 answer

How to change slug before use in friendly_id gem?

I am trying to convert slugs to normal characters before using it in Friendly ID, but it does not work: class CompanyJob < ApplicationRecord extend FriendlyId def self.convert_slug(title) n = title.downcase.to_s n.gsub!…
Dung Nguyen
  • 39
  • 1
  • 7
0
votes
1 answer

Rails not differentiating between two resources nested in the same namespaces

I have two types of products that are nested under the same categories. The routes I have setup are resources :categories, path: '/', only: [:show] do resources :subcategories, path: '/', only: [:show] do resources :amazon_products, path: '/',…
rosalynnas
  • 414
  • 7
  • 18
0
votes
1 answer

How to use named routes when using FriendlyId at the root path in Rails

I have a basic Page model in Rails that I'm using with FriendlyId to allow admins to create pages like "/about" or "/contact". I have the following in my routes file (config/routes.rb) to ensure that the slugs for each page appear at the root of the…
Lee McAlilly
  • 9,084
  • 12
  • 60
  • 94
0
votes
1 answer

undefined method `slug_limit=' for friendly_id

When I set the slug_limit on friendly_id as per the documentation in the initializer, I see the following error: Failure/Error: extend FriendlyId NoMethodError: undefined method `slug_limit=' for…
Rimian
  • 36,864
  • 16
  • 117
  • 117
0
votes
1 answer

Friendly_id not working version 5.3 rails 6

I've been working on an app and I installed friendly_id version 5.3 and everything was working. However, recently working on the app I've found friendly_id not working at all on anything it's been set on. So for this, I'm going to use the…
Ben Bagley
  • 733
  • 1
  • 9
  • 22
0
votes
1 answer

How to differentiate between :ids in routes/URL that belong to different models using FriendlyID?

I'm wondering how to generate a url that includes friendly ids for two different models. For example, if you have a post titled 'Rails Tutorial' and belonging to a particular User named 'Michael', and they each use a slug in place of their ID, how…
0
votes
0 answers

Can not transliterate strings with CP850 encoding

For my Blog App I use FriendlyId to generate slugs. In irb post creation process following message appears: ArgumentError (Can not transliterate strings with CP850 encoding) I found out that the error appears because of a space between words in the…
0
votes
1 answer

Rails friendly_id removing non ascii characters for url generation

I want to auto generate the slug based on the title and author of the book, which can be in any language. Using friendly_id with rails, and when there are non-ascii characters, it just removes them. I know I can technically include by encoding them…
gwalshington
  • 1,418
  • 2
  • 30
  • 60
0
votes
1 answer

Rails: friendly_id and to_json

I have a collection of model objects that I am trying to return JSON for. E.G @regions.to_json(:only => [:id, :name ]) that works fine. If I try to use : @regions.to_json(:only => [:friendly_id, :name ]) then nothing is returned for the…
patrickdavey
  • 1,966
  • 2
  • 18
  • 25
0
votes
0 answers

How to use friendly_id to find product?

I installed friendly_id according to the instructions. And use it for products. For show i use: @product = Product.friendly.find(params[:id]) And it works. But I have a couple of question, on its use for other controllers. In cart_item_controller i…
SsPay
  • 161
  • 9
0
votes
2 answers

Exclude using friendly_id?

I want to run a controller query and exclude the current (self) record. I can use this: Model.where.not(slug: params[:id]) That works fine until you manage to pass the record id. Is there a cleaner more direct way to do this? UPDATE I clarified my…
Dan Tappin
  • 2,692
  • 3
  • 37
  • 77
0
votes
1 answer

Configure user url with username in it, but no association of model

Using Rails 2.3.8, and friendly_id. Person model: class Person < ActiveRecord::Base # Nice URL's in Rails. def to_param "#{login.downcase.gsub(/[^[:alnum:]]/,'-')}".gsub(/-{2,}/,'-') end end People controller: class PeopleController <…
Victor
  • 13,010
  • 18
  • 83
  • 146
0
votes
1 answer

FriendlyId: undefined method `use_slug?' for nil:NilClass

I am creating a new environment besides production. I copied all the configurations from my production environment, changing what needed to be changed. As it is the servers do start, but when I do a query I get this exception: NoMethodError…
0
votes
1 answer

Trying to add :id to the end of paramter in Rails app

I'm trying to modify my url parameter in my app. I'm currently using friendly_id to make the url include the title instead of the id. However I'd like to add the id after the title in the url if possible. example: current:…
Bradley
  • 922
  • 2
  • 8
  • 24