产品列表的类别或类别的产品

时间:2017-07-20 12:35:33

标签: ruby-on-rails ruby friendly-id

class Product < ApplicationRecord
    extend FriendlyId
    translates :name, :slug, :description
    friendly_id :slug_candidates, use: :globalize
    globalize_accessors :locales => [:tr, :en, :ar], :attributes => [:name, :slug, :description]
    has_and_belongs_to_many :categories, join_table: 'products_categories'
class Category < ApplicationRecord
    acts_as_nested_set
    extend FriendlyId
    translates :name, :slug, :description
    friendly_id :slug_candidates, use: [:globalize, :slugged, :finders]
    globalize_accessors :locales => [:tr, :en, :ar], :attributes => [:name, :slug, :description]

    has_and_belongs_to_many :products, join_table: 'products_categories'
Product.search_by_product_name(parameters[:oyun]).eager_load(:categories)
Product.eager_load(:categories).search_by_product_name(parameters[:oyun])

我想列出产品类别或产品类别。

0 个答案:

没有答案