0

I have many categories . so when I am viewing them I want to be able to see that categories name , not the id of the category.

At this moment I have like this.

http://postimage.org/image/5fb5uzhzd/

But I want after categories/category_name .

I don't want that You say me everything, I just need some tip. So I could do the research.

Does this funcionality is somehow connected to the routes ?

Thanks :)

4

2 に答える 2

1

You can use the friendly_id gem to achieve that. You will find all the explanation you need to implement this feature in this Railscasts episode.

Or you can do it manually by following this other Railscasts episode.

于 2013-03-13T13:27:26.187 に答える
0

If the category_name is something that can be placed in url (like no spaces and so) you can achieve that by simply overriding to_param method in your model

class Category
  def to_param
    category_name
  end
end
于 2013-03-13T13:41:37.950 に答える