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
1
vote
2 answers

Hiding a resource name in FriendlyID slug

I'm using FriendlyID to produce slugs for some of my models. To use the example provided in the FriendlyID docs ( http://rubydoc.info/github/norman/friendly_id/master/frames ), my URLs currently look like…
simonrohrbach
  • 512
  • 4
  • 17
1
vote
1 answer

friendly_id, Seeding database, Undefined method 'friendly_id'

In a Rails 3 app, I am trying to write seeds (in db/seeds.rb) for a model that uses friendly_id: # /db/seeds.rb Page.create(:title => "Default page", :content => "Default content of the default page") When I run rake db:seed the task fails. Below…
Jay
  • 2,861
  • 3
  • 29
  • 51
1
vote
1 answer

Why does friendly_id default to two dashes?

Curious as to why friendly_id encourage 2 dashes, instead of one? Am interested why this is the default logic. Any reason why they chose two dashes, instead of one?
Christian Fazzini
  • 19,613
  • 21
  • 110
  • 215
0
votes
1 answer

newbie: issues with updating / redirect profile and friendly_id

Trying to rewrite my profile controller wich is broken at this point. Im using friendly_id to have urls like below with partials edit_basics.haml, edit_details.haml, etc. /users/me/edit/basics /users/me/edit/interests /users/me/edit/details The…
0
votes
1 answer

Friendly_id not working, redirects to Category with wrong index

I've followed Ryan Bates' screencast in order to get friendly_id set up (up until the def should_generate_new_friendly_id? part) for my Category model. One of the Categories is books, but for some reason /categories/books redirects to a blank page,…
varatis
  • 14,494
  • 23
  • 71
  • 114
0
votes
1 answer

friendly_id on profile using a param from user model?

Im following the casts http://railscasts.com/episodes/314-pretty-urls-with-friendlyid?autoplay=true on friendly_id Having a user model with field "login" And a profile model with a "user_id" that belongs to user How could I setup friendly_id so…
Rubytastic
  • 15,001
  • 18
  • 87
  • 175
0
votes
3 answers

How do I move example.com/profiles/1 to example.com/username with friendly_id with username from user model?

I have red docs on friendly_id for rails. It's easy: you set a certain attribute to be the slug. example.com/username User has_one profile Profile belongs_to User So you see my dilemma. I have no column username in the profile model. How can I link…
Rubytastic
  • 15,001
  • 18
  • 87
  • 175
0
votes
2 answers

How do i solve friendly id issue in active admin

I am using Rails 7 Active admin I have Project that is Workshop Project that is related to organizing workshops, booking them etc. I am using Friendly ID Gem . The url looks like http://127.0.0.1:3000/workshops/ai-the-new-era using friendly id. Now…
0
votes
1 answer

Redirect to the canonical slugs using FriendlyId gem while using CanCan gem

Let's say you have a model Speaker that utilizes FiendlyId gem to create unique slugs like this: class Speaker < ApplicationRecord friendly_id :name, use: %i[slugged history finders] end And you are using CanCanCan gem to implement authorization…
AliOsm
  • 541
  • 2
  • 6
  • 20
0
votes
1 answer

Rails Undefined method `friendly_id' using friendly_id gem

I've looked at similar posts on SO and YouTube videos, but can't seem to figure out why I'm getting this error for a blog site: undefined method `friendly_id' for BlogPost:Class Ideally, my URL should be: www.mysite.com/blog-title-here blog_post.rb…
AntMar
  • 23
  • 6
0
votes
2 answers

Why is my custom slug method skipping it's code?

I am trying to perform the following actions to alter my urls: parse instances of "an-" from my url remove a prefix of "the-" from my url if present. class BlogPost < ApplicationRecord extend FriendlyId friendly_id :custom_slug, use:…
Jake
  • 1,086
  • 12
  • 38
0
votes
1 answer

How to add the name of a blog post's category to route url with Rails 7

I have been trying to add the name of the BlogCategory that a BlogPost belongs to in a URL such as this: sitename.com/blog/category-name/blog-post-title At the very least, I want this to render for the show of the BlogPost but am okay with it being…
Jake
  • 1,086
  • 12
  • 38
0
votes
0 answers

Rails: Use strings like "1", "1.2", "1.2.1", and "1.2.1a" as ID values of a model

I have a tree-like structure of the Web Content Accessibility Guidelines (WCAG) with my model wcag_elements. class WcagElement < ApplicationRecord acts_as_tree order: :position def to_param "#{id}-#{name.parameterize}" end end The tree…
Joshua Muheim
  • 12,617
  • 9
  • 76
  • 152
0
votes
0 answers

ActiveRecord::RecordNotFound Issue in Rails

I see the above issue while accessing active admin show page for model "campaign". This might be due to friendly_id gem, but I'm unable to identify what exactly the issue is. My campaign.rb file looks like following: class Campaign <…
Fuaad
  • 197
  • 15
0
votes
1 answer

Translate friendly_id

Using: Rails: 3.0.3 Friendly_id: 3.2.1 I am building a website with (currently) two locales, :se & :en where I am using friendly_id to get SEO-friendly url. Currently, it works fine but I am trying to get it to work with locales and end up in dead…
Christoffer
  • 2,271
  • 3
  • 26
  • 57