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
0 answers

Do not allow access with simple ids

How do I have to set my routes in a way that pages can not be accessed anymore with simple ids, but only with friendly_ids? I do not want that people are able to access a certain page just entering the id of the object. EXAMPLE: I do want to access…
0
votes
2 answers

undefined method `name' for nil:NilClass for custom slug

I have a Restaurant model that use Geocoder to gather the city, state, and neighborhood on a before_validation callback. class Restaurant < ActiveRecord::Base # attrs: :name, :address, :city_id, :neighborhood_id ... before_validation…
Carl Edwards
  • 13,826
  • 11
  • 57
  • 119
0
votes
2 answers

Using the Friendly ID gem with Rails, how do you regenerate the slug field?

I'm building a rails app that hosts games. Games belong to categories and thus each category can have many games. I'm using the Friendly_id gem to generate URL slugs and have the following setup: Category.rb class Category < ActiveRecord::Base …
dnyce
  • 415
  • 1
  • 6
  • 20
0
votes
0 answers

undefined method `to_model' for 1:Fixnum

artist/show.html.erb <% if @artist.songs.any? %>
<% @artist.songs.each do |song| -%> <%= link_to song.title, song.artist %> <% end -%>
<% end %> Routes.rb resources :artists, :path =>…
anouar
  • 125
  • 1
  • 1
  • 10
0
votes
1 answer

trouble with friendly_id gem, issues when trying to target the correct id

So I am building a website for school that consists of different wikis that users can create, update, edit, etc. On my wiki edit page I allow an option for premium users to add or remove collaborators to a wiki that they have created if they choose…
jlquaccia
  • 165
  • 3
  • 13
0
votes
1 answer

Is there way to use friendly_id for not unique value

I'm writing a rails project that is about stock market. There is a ticker symbol that represent a company. e.g. "AAPL" for Apple. But the ticker symbol is only unique for current listed companies, the symbols are duplicated when delisted companies…
ironsand
  • 14,329
  • 17
  • 83
  • 176
0
votes
2 answers

Friendly_id and globalize - use default translation for slug if translation is missing

I have integrated friendly_id gem and globalize and it works just fine if I have translation for slug in specific locale. But what I want to achieve is to use default translation for slug in case it is missing in translation table for some…
Miroslav
  • 158
  • 2
  • 22
0
votes
1 answer

Implementing /YYYY/MM/Title-Slug URL structure with Friendly_Id

I'm really hoping someone can help this Rails n00b with this issue. I've been researching, trying, crashing(-and-burning) over the past few days on how to implement the standard /YYYY/MM/Title-Slug URL structure for a blog I'm putting together. I've…
Brian M.
  • 170
  • 1
  • 1
  • 10
0
votes
1 answer

Ruby On Rails: friendly_id on acts_as_taggable_on, updating slug column

I think I have it setup properly per these answers But when I'm trying to update the slug column in an existing app like so for my tags: Tag.find_each(&:save) I'm getting this error: NameError: uninitialized constant Tag Is Tag not the correct…
hellomello
  • 8,219
  • 39
  • 151
  • 297
0
votes
3 answers

friendly_id gem for current_user

I've been trying to figure out how to use the current_user user_name as their url. Currently it looks like http://localhost:3000/users/2 instead of http://localhost:3000/users/user_name. All help is appreciated. For any questions, please ask.…
Jake
  • 462
  • 1
  • 5
  • 13
0
votes
1 answer

Rails: How to pass params from a friendly_id url to a controller?

I have an URL : Example.com/searchjobs/jobs/sales So, I just want to pass 'sales' keyword to my @query variable in my controller, but it remains nil. I tried several tutorials but they only show how to use friendly_id with a model. Thanks for your…
reme
  • 183
  • 1
  • 1
  • 12
0
votes
1 answer

Rails friendly_id: undefined method `slug` on production

I'm trying to introduce dynamic_sitemaps over resources with friendly_id. The issue is the production rails (rake / rails c) doesn't see the slug method. I've try to specify it by force by specifying an attr_accessible :slug, but it doesn't help…
lifecoder
  • 1,424
  • 1
  • 14
  • 29
0
votes
3 answers

friendly_id creates new entry on UPDATE

I'm using friendly_id 5.1.0, and when I try to update an entry, for exemple creating a new Article, instead of updating the data of the entry, it creates a new one. I have slugged the title and when I don't change it when editing an article, it…
TheDoctor
  • 23
  • 1
  • 6
0
votes
1 answer

FriendlyID does not find entry with matching slug

FriendlyID does not seem to find a database entry with the corresponding slug. Here is what the console shows: Started GET "/budgets/drinks" for 127.0.0.1 at 2015-07-01 12:42:53 +0200 Processing by BudgetsController#show as HTML Parameters:…
sam
  • 1,711
  • 1
  • 17
  • 24
0
votes
1 answer

Rails 4 LocalJumpError for nested recourse form

I have a nested recourse called "transactions" inside another recourse "budgets". All I'm trying to accomplish is for my users to be able to edit individual "transactions". However when I go to /1/transactions/1/edit I get a LocalJumpError saying…
sam
  • 1,711
  • 1
  • 17
  • 24