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

Friendly ID for duplicates

Let's say we have 2 posts with the same titles: "superheros". The first post should have url superheros-alternative-1 and the second one should have superheros-alternative-2. The problem is that when I am updating a title of one of these posts, the…
Artem Halas
  • 153
  • 1
  • 2
  • 15
0
votes
1 answer

Rails 3: when no current_user(no user logged in) friendly_id sends username as :id but controller method does not work

I'm using friendly_id gem and it's working properly when I go to a user's profile page as a logged in user: localhost/users/facebookname When I log out and go to the profile page it displays the url same way, no problem. However, when I attempt to…
user1009762
  • 199
  • 3
  • 11
0
votes
1 answer

How can I override a class in Rails?

I am using this gem, friendly_id, but I need to establish a connection to another database where the table is currently stored. This is because I am managing resources on this application for another application. How would I override this class so…
0
votes
1 answer

When trying to update multiple records Rails can't find the record with id while using friendly_id

When we use friendly_id, Rails can't update multiple records at a time. Here's my controller line which update the records : @submitsup = Photo.update(params[:submits].keys, params[:submits].values) Here's the error I get…
THpubs
  • 7,804
  • 16
  • 68
  • 143
0
votes
1 answer

Rails - friendly_id - How can I generate friendly_id slug from a text field

rails newbie here I am using friendly_id gem, I have a Page model when I create page a friendly_id slug generate from title given in text field, What i want is to able to edit that slug and do not change on update or when i change the title here is…
Majid Mushtaq
  • 319
  • 1
  • 3
  • 14
0
votes
1 answer

Creating a FriendlyId with a one-to-many relationship

I have a User model that has a has_many relationship with a Post model. Class User < ActiveRecord::Base has_many :posts end Class Post < ActiveRecord::Base attr_accessor :user_id belongs_to :user end I'd like to setup the url of my post…
Carl Edwards
  • 13,826
  • 11
  • 57
  • 119
0
votes
1 answer

Rails: Associating two different models when not using params[:id]

I have two models Author and Post. I want an author to be able to create posts and have an association between those two models. I normally do this by nesting author and posts so the url would look like author/:id/posts. In this case, I use…
DJF
  • 47
  • 1
  • 3
0
votes
1 answer

change post/:id in rails to show post/:restname

I'm still new to Rails and I have a question about routes. Right now, I have resources from a post table as normal. post_path GET /posts/:id(.:format) posts#show PATCH /posts/:id(.:format) posts#update …
nyhunter77
  • 614
  • 2
  • 7
  • 19
0
votes
0 answers

rails app - Friendly_id cut url

my rails application generates the following URL : www.mysite.com/chicago?area_id=4 I'd like to "cut" it to : www.mysite.com/chicago Is it possible to do so using friendly_id ? Thanks
skess mousse
  • 105
  • 1
  • 10
0
votes
1 answer

Stackoverflow Style URL's with Friendly_ID

I was able to setup friendly_id with one of my models (categories), but I need help with setting up with another model. Basically I want the URL's to be something like this: domain.com/129121/title-of-post where 129121 is the ID of the post. I…
nahtnam
  • 2,659
  • 1
  • 18
  • 31
0
votes
2 answers

Why is Friendly_ID gem using slug instead of primary key?

I'm getting an error from rails after installing Friendly_ID because the code is misinterpreting the input, and I don't know how to fix the problem. In order for the MVC framework to understand the url and route it accordingly, the url needs to fit…
elersong
  • 756
  • 4
  • 12
  • 29
0
votes
1 answer

Rails 4.1 - Saving friendly_id slug for many records en masse

I have a database with a few million entities needing a friendly_id slug. Is there a way to speed up the process of saving the entities? find_each(&:save) is very slow. At 6-10 per second I'm looking at over a week of running this 24/7. I'm just…
viotech
  • 105
  • 1
  • 10
0
votes
1 answer

How to use friendly_id with a relationship between 2 models?

I have 2 relationships that need to be used in 1 model. The error I am getting is: ActiveRecord::RecordNotFound at /books/booky-wook Couldn't find Gallery with id=booky-wook def show @book = Book.friendly.find(params[:id]) @gallery =…
0
votes
1 answer

Is there a way to expire FriendlyId slugs after a certain time?

I'd like to give my users the ability to change their slugs and have their old slugs redirect. But after some time, I'd like to have the old slugs become available. Is there an official or recommended way to do this? I suppose it's as simple as…
John Bachir
  • 22,495
  • 29
  • 154
  • 227
0
votes
1 answer

How to use friendly_id history with nested resources

I have User and Campaign models. I nest campaigns under users and URLs look like this: http://localhost:3000/user-slug/campaign-slug Routes: resources :users, :path => '' do resources :campaigns, :path => '' end Campaign model: class Campaign <…
Aen Tan
  • 3,305
  • 6
  • 32
  • 52