My backend use Rails and postgresql, and I have two model like:
class Order < ActiveRecord::Base
has_many :products
...
def arrange_products
self.products.select("name, SUM(amount) as sum_amount").group("name").having("SUM(amount) != ?", 0)
end
...
end
class Product < ActiveRecord::Base
belongs_to :order
...
end
The arrange_products like has_many, but there are no id.
So in ember data use hasMany could not work.
Now I set attr for arrange_products in Order model:
export default Model.extend({
products: hasMany('product'),
...
arrange_products: attr('')
});
But I think it is not best way solve thie problem. So there is a good solution to this situation? Thanks.
Aucun commentaire:
Enregistrer un commentaire