0

I want to be able in browsing bar see full path to some product. The path would look like this

www.mysite.com/categories/category_name/subcategory_name/product_name

At this moment I have just www.mysite.com/categories/category_name It just provides with one level path, that I don't need.

To build these friendly links I used friendly_id. And full categorization function I created using gem called Ancestry.

How can I modify friendly_id slug so that I can show the full path? I know how the friendly_id works, but I don't know how to change the way how slug is generated.

Some guys could just give me link or tip to search for. I can work it out, I just need idea. I would be very greatfull :) :)

Edgars
  • 913
  • 1
  • 19
  • 53

2 Answers2

1

You're probably looking for nested resouces. If both models (category, subcategory) have slugs, nesting them in your routes.rb file should do the trick:

resources :categories do
  resources :subcategories
end
mihai
  • 37,072
  • 9
  • 60
  • 86
1

You can pass a method for the gem to use, as in:

extend FriendlyId
friendly_id :method_name, use: :slugged

def method_name

end
RailinginDFW
  • 1,523
  • 12
  • 19