How can I group/reuse named scopes in Rails? -
How do I group a named SCOPE? For example, I have two models, users, and activity, a user may have multiple activities.
The activity has two named scopes:
activity .ordered_by_created_at activity.top_20 I want to have a new designated scope < Create code> activities. such as
activity.recent == activity .ordered_by_created_at.top_20 In this way, I user.activities I can call recently
user.activities.recent Is this possible? Thank you.
When you call the user. ACTIVITY, INTRODUCE you have close_you: Relationship to activities in your user. RB files, activatecord will return an array of all user activities.
Now a la actti. recent. Consider changing the approach of the user (UID) and only your activity. In the RB file, a named_scope finds the users associated with the activity
Comments
Post a Comment