How to rewrite below URL
127.0.0.1:3000/article/index?type=1
as
127.0.0.1:3000/article/category/brand
where type 1 is category with name brand.
is it possible using rails?
route.rb
get "article/index"
article_controller.rb
def index
@article = Article.find(params[:type])
end
article.rb //model
class Article < ApplicationRecord
belongs_to :category
end
link to this route
<%= link_to category.name, {:controller => "article", :action => "index", :type => category.id }%>