To configure this, you start with a route that performs “routing”:
match "*category" => "categories#show"
or
match "categories/*category" => "categories#show"
in your controller, you will get all parts of the url through a hash params. To keep clean, define the search logic in your model
def show
@category = Category.find_recursive(*params[:categories])
end
in your model, define a category search method. I assume act_as_tree is defined in your model
def self.find_recursive(*categories)
children = roots
last = nil
categories.each do |category|
return unless children
last = children.find_by_permalink(category)
children = last.children
end
last
end
source
share