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

Have friendly_id slugs only applied if condition x

I have friendly_id applied and working but now I dont want it to add a slug if the key_type is 4 currently I have extend FriendlyId friendly_id :value, :use => :scoped, :scope => [:category_item_key, :category_item] and tired applying an if…
Rob
  • 1,835
  • 2
  • 25
  • 53
0
votes
2 answers

Trying to .slice data in the model before it is saved to the db but it isn't working

I'm trying to have the slug length be less than 20 if the key_type is 4. In the model I have validate :text_slug_length def text_slug_length if key_type == 4 slug.slice(0, 19) end end But this doesn't throw any errors but also doesnt work.…
Rob
  • 1,835
  • 2
  • 25
  • 53
0
votes
1 answer

Set FriendlyID slug for relationship table in Ruby on Rails

I want to set slug from relationship table name How can I? For example Patient Table Info Id contact_id ... Contact Table Info FirstName - String LastName - String ... Patient Model Having below code extend FriendlyId friendly_id :full_name, use:…
Dipak Panchal
  • 5,996
  • 4
  • 32
  • 68
0
votes
1 answer

Trouble accessing attributes of associated read only model

I'm using the friendly_id gem to generate slugs. I have a model like this class Veterinarian < ApplicationRecord extend FriendlyId belongs_to :user has_one :profile, through: :user friendly_id :slug_string, use: :slugged def…
Mike
  • 286
  • 4
  • 15
0
votes
1 answer

Couldn't find Weekly without an ID (Deleting in Rails)

In my app I have models called weeklies and scores. Each weekly has_many scores and each score belongs_to a weekly and a user. I have the create and show methods working just fine, but when I try to delete a score I get Couldn't find Weekly without…
Liz
  • 1,369
  • 2
  • 26
  • 61
0
votes
1 answer

How to get actual post.id while using friendly_id

I currently have my post model using friendly_id to replace Post.id with Post.pid: friendly_id :pid, :use => :scoped, :scope => :id How can I get the actual id of a post instead of the slug so that when a reply saves it saves Post.id and not…
indus
  • 103
  • 1
  • 10
0
votes
1 answer

freindly_id returns 0 for named url

Using the line: @post = Post.friendly.where!(:board_id=>params[:board_id]).find(params[:id]) to separate posts :board_id returns a 0 when the url is /board1/thread/1/, but returns the correct value of 1 when the url is /1/thread/1/ How can I get the…
indus
  • 103
  • 1
  • 10
0
votes
1 answer

friendly id path in checkbox_tag rails 4

I'm currently getting this in my checkboxes data-url "/todos?id=f483e4a8cb1a728f" when it should just be "/todos/f483e4a8cb1a728f" I'm using friendly id for the random slugs. Currently I'm calling it as data: { remote: true, url:…
Stuart Pontins
  • 285
  • 4
  • 14
0
votes
0 answers

FriendlyId returning duplicate slugs for STI sub classes

I am using Rails 4.1.14.2 and FriendlyId 5.0.3 I have a Project class that has multiple Topics. Topic slugs need to be unique across all topics within the same project. My routes are like localhost/:project/sub-topic-slug Topics class uses…
LearingRoR
  • 11
  • 3
0
votes
2 answers

Random slug url for friendly id gem in Rails 4

Has anyone ever used random_slug (https://github.com/josei/random_slug) for friendly_id? It was last updated 5 years ago so I'm not sure if it's a waste of time to try it out or even if there is a better solution? Basically I have friendly_id…
Stuart Pontins
  • 285
  • 4
  • 14
0
votes
1 answer

Ruby on Rails 4 - FriendlyID ID's based on users?

Is it possible to separate IDs on a per user basis? For example; I set up devise for users and friendly ID for nice slugs rather than 1, 2, 3 etc. However, if two users make a todo with the same name, then it's still counted as a duplicate even if…
Stuart Pontins
  • 285
  • 4
  • 14
0
votes
1 answer

breadcrumbs_on_rails compatibility with Friendly ID

I'm using breadcrumbs_on_rails and Friendly ID in one of my projects. def show @section = Section.friendly.find(params[:id]) add_breadcrumb 'Introduction', section_path(@section) end This doesn't return an active link in the html, just plain…
William Holt
  • 549
  • 4
  • 14
0
votes
1 answer

Rails Friendly_id error when Field Blank

I have the friendly_id initializer to shorten the value if there is a duplicate value in the database. # over writing the conflict slug module FriendlyId module Slugged def resolve_friendly_id_conflict(candidates) candidates.first +…
Harsha M V
  • 54,075
  • 125
  • 354
  • 529
0
votes
1 answer

Rails activerecord - cannot access column slug

I have decided to add slugs to my URLs, I added a column named "slug", created migration, successfully migrate it, verified the existence of a column in the database: But I am unable to create records because I get a following error: NoMethodError:…
Giron
  • 350
  • 3
  • 16
0
votes
1 answer

Fliendly_ID - URL not being displayed

I am new to ROR and working on a small project. Recently I added the friendly ID gems and followed the instruction on the documentation. But I can't seem to get the URL working. I added the friendly id to communities model which is basically your…