There are several models:
class Product < ActiveRecord::Base extend FriendlyId friendly_id :name, use: :slugged belongs_to :material belongs_to :color end class Color < ActiveRecord::Base extend FriendlyId friendly_id :name, use: :slugged has_many :products end class Material < ActiveRecord::Base extend FriendlyId friendly_id :name, use: :slugged has_many :products end
Suppose you choose one parameter in each:
material: 'wood' color: 'gray'
It is necessary to find all products with such values. And now the most interesting, it is necessary that the URL was not site.com/search?utf8=✓&..wood..gray
, but site.com/wood/gray
, and there was an opportunity to put the title
, description
and keywords
.
I heard that you can somehow create a model for intersections, but did not understand.