class TransactionItem < ActiveRecord::Base
belongs_to :transaction
end
class Transaction < ActiveRecord::Base
has_many :transaction_items
def items
self.transaction_items
end
end
class CategoryItems < ActiveRecord::Base
belongs_to :category
end
class Category< ActiveRecord::Base
has_many :category_items
def items
self.category_items
end
end
In an effort to simplify the interface to Objects
that have Items
bu erda ko'rganim yo'qmi? Ushbu maqsadga erishish uchun yoki undan yaxshi yo'l ?
category = Category.first
category.items
# instead of
# category.category_items
transaction = Transaction.first
transaction.items
# instead of
# transaction.transaction_items