0

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
  • friendly_id used to change your app urls to http://example.com/states/washington instead of: http://example.com/states/4323454 ,what do you mean of first_post ? – Remon Amin Feb 02 '14 at 21:10

2 Answers2

3

There should a method called friendly_id

@post.id # => 1
@post.friendly_id # => first_post

Hope this helps

strivedi183
  • 4,749
  • 2
  • 31
  • 38
1

Alternative to @post.friendly_id:

@post.slug # => first_post
Darpa
  • 396
  • 1
  • 8