I have three models: users, products and ownership One is owned by App / model / product.rb But when I do Here is a connection between my users and products: App / model / user.rb To set an order on products owned by a user, You can specify. For example: product_id: integer and a
user_id: integer . I want to give my products the scope by
created_at DESC .
. . Default_scope - & gt; {Order ('products.created_at DESC')}. .
user.owned_products , then it has not been ordered as
created_at DESC . How can I do that? Will I add an opportunity to my user model?
. . . Has_many: is proprietary has_many: own_products, through :: proprietorship, source :: product. .
has_many: own_products, via :: Ownership, Source :: Products, Order: "created_at DESC"
No comments:
Post a Comment