Sha256: 14ff6a69975ca8ec5113be0d7b4f3bc35e7538d624224ac64e96012dd4e9fe82

Contents?: true

Size: 372 Bytes

Versions: 16

Compression:

Stored size: 372 Bytes

Contents

class Category < ActiveRecord::Base
  has_many :category_items
  has_many :products, through: :category_items
  belongs_to :store

  def as_json(*args)
    {
      name: name,
      store_name: store.name,
      category_items: category_items.map do |item|
        {
          name: item.name,
          product_name: item.product.name
        }
      end
    }
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
thermos-0.5.1 test/dummy/app/models/category.rb
thermos-0.5.0 test/dummy/app/models/category.rb
thermos-0.4.1 test/dummy/app/models/category.rb
thermos-0.4.0 test/dummy/app/models/category.rb
thermos-0.3.0 test/dummy/app/models/category.rb
thermos-0.2.1 test/dummy/app/models/category.rb
thermos-0.2.0 test/dummy/app/models/category.rb
thermos-0.1.1 test/dummy/app/models/category.rb
thermos-0.1.0 test/dummy/app/models/category.rb
thermos-0.0.8 test/dummy/app/models/category.rb
thermos-0.0.7 test/dummy/app/models/category.rb
thermos-0.0.6 test/dummy/app/models/category.rb
thermos-0.0.5 test/dummy/app/models/category.rb
thermos-0.0.4 test/dummy/app/models/category.rb
thermos-0.0.3 test/dummy/app/models/category.rb
thermos-0.0.2 test/dummy/app/models/category.rb