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

Why is friendly_id working in one action and failing in another

I have some custom actions in my orders_controller.rb: class OrdersController < ApplicationController def process_payment @order = Order.friendly.find(params[:id]) [snip] binding.pry_remote # drops into the terminal here for debugging …
steven_noble
  • 4,133
  • 10
  • 44
  • 77
0
votes
1 answer

use permalink instead of slug in friendly-id

I am new to friendly-id and i have this in my post.rb model extend FriendlyId friendly_id :title, use: :slugged and friendly_id generator migration is def change create_table :friendly_id_slugs do |t| t.string :slug, :null =>…
Asnad Atta
  • 3,855
  • 1
  • 32
  • 49
0
votes
1 answer

Friendly_id: In a model how to slug a second column value when value in first column is absent

I am using Ruby 2.1.1 and Rails 4.0.4. In my model I have two columns A & B. How do I slug value of B when value in column A is absent? I want to keep column A value primarily. It is only when the value in column A is absent.
Subrat Rout
  • 95
  • 2
  • 16
0
votes
1 answer

Trouble referencing logged in user in Rails

I am new to Ruby on Rails I am using Michael Hartl's tutorial on RoR and trying to add Paperclip to do profile pictures for users. I am also using Friendly_Id on the users if that helps. I get this error for one of my views. I am not sure why it is…
0
votes
0 answers

2 save to update my alias with friendly ID

I'm using the gem Friendly ID, and I currently have to do 2 saves in order to save the slug. It doesn't seems right to me. class Contractor < ActiveRecord::Base include FriendlyId friendly_id :slug_candidates, use: :slugged, slug_column: :alias …
bl0b
  • 926
  • 3
  • 13
  • 30
0
votes
1 answer

`Couldn't find User without an ID` with Friendly_ID gem

I am creating User Profiles with vanity URLs that use the username. The actual profile page works well, however I have my root page as the profile page if the user is signed in. If they are redirected to root then they get the error Couldn't find…
Taylor Mitchell
  • 614
  • 11
  • 27
0
votes
1 answer

Friendly_Id - defining slug candidates

I have a model called users, in which users have usernames. I have another model called educators, which has many users. I want to put friendly_ids on the educators model, and I want the slug to include the username (which is not referenced in the…
Mel
  • 2,481
  • 26
  • 113
  • 273
0
votes
1 answer

`slug` is not updated when update referenced column with friendly_id 5.0.2

I want to update slug column when screen_name is updated, so I write like this. class User < ActiveRecord::Base extend FriendlyId friendly_id :screen_name, use: :slugged def should_generate_new_friendly_id? slug.blank? ||…
ironsand
  • 14,329
  • 17
  • 83
  • 176
0
votes
1 answer

Customizing Friendly_id URL

First I am sorry for my English I am using Friendly_id gem to create Clean URL and it work just fine but instead of having a URL like this http://localhost:3000/profile/jack-sparo I want a URL like this…
Loenvpy
  • 899
  • 1
  • 10
  • 30
0
votes
2 answers

Rails: routes whith Friendly id gem

First sorry for my english i am french I am using Frindly_id gem to generate clean url and it work just fine i still have a problem, for example let's say i have a user with user_id=1 and a full_name = = "olivier logaro" so when i go to this user…
Loenvpy
  • 899
  • 1
  • 10
  • 30
0
votes
0 answers

Rails 4, cancan, devise,friendlyid - running the same query multiple times

Maybe there is something about the way cancan runs that is causing this. I have a page that shows a list - and each item in the list checks for authorisation. I am using a friendly slug on the User model. I tried using load_and_authorize_resource…
user2515011
  • 127
  • 1
  • 12
0
votes
2 answers

Rails: friendly_id

I'm using friendly_id gem in my app. How can I get object's friendly id? When I write @post.id I get 1 but how can I get first_post instead?
Pavel
  • 1,934
  • 3
  • 30
  • 49
0
votes
2 answers

Friendly_Id slugs with ids or dates separated by slashes

I'm using the Friendly_Id 5 gem in my Rails 4 app to make the URL's "friendlier." I can currently generate URLs like /article/my-article-title. On many blog's today, you also see the date or the id in the path. How would I generate URLs like: …
CodeSmith
  • 2,133
  • 1
  • 20
  • 43
0
votes
1 answer

custom route for show action using slugs

I'm attempting to create some urls for a model that I want display. I have articles, which belong to sections which belong to issues. I would like my URLs for the article show action to look like this: /issue-slug/section-slug/article-slug issues…
user922592
0
votes
0 answers

Friendly_id gem: updating fields doesn't use candidates array?

I have my slug candidates set as : def slug_candidates [ :full_name, [:full_name, :location], :display_name ] end def should_generate_new_friendly_id? full_name_changed? || location_changed? || display_name_changed? end But if…
Hopstream
  • 6,391
  • 11
  • 50
  • 81