In @activities = PublicActivity::Activity.order("created_at desc").where(owner_id: current_user.friend_ids, owner_type: "User")
where did current_user.friend_ids come from?
friend_id is an attribute of Friendship, not User, right? And you can just pluralize an attribute to get an array?
Sorry, but you just blew my mind with Page.find_each(&:save)
I knew about find_each for batch loading, but what the heck is &:save and where else can I use it?
I mean, obviously I can see what it's doing, but can I use this anywhere a block is expected? When can't you use this notation?
Not well documented at all, but I found an answer so I'll answer here because Google brought me here:
ActiveAdmin.register Post do
scope :posted_by_tom_cruise do
Post.posted_by("Tom Cruise")
end
...
I wish someone had an answer for this
Might be a basic Rails question but:
In
@activities = PublicActivity::Activity.order("created_at desc").where(owner_id: current_user.friend_ids, owner_type: "User")
where did
current_user.friend_ids
come from?friend_id is an attribute of Friendship, not User, right? And you can just pluralize an attribute to get an array?
Sorry, but you just blew my mind with
Page.find_each(&:save)
I knew about find_each for batch loading, but what the heck is
&:save
and where else can I use it?I mean, obviously I can see what it's doing, but can I use this anywhere a block is expected? When can't you use this notation?
I was wondering when someone was going to mention that, and how much weight should be given to the author's advice...
I was wondering when someone was going to mention that, and how much weight should be given to the author's advice...