문제

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?

도움이 되었습니까?

해결책

There should a method called friendly_id

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

Hope this helps

다른 팁

Alternative to @post.friendly_id:

@post.slug # => first_post
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top