RailsCasts Pro episodes are now free!

Learn more or hide this

Stephen Hunter's Profile

GitHub User: Arcolye

Comments by Stephen Hunter

Avatar

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
...

Avatar

I wish someone had an answer for this

Avatar

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?

Avatar

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?

Avatar

I was wondering when someone was going to mention that, and how much weight should be given to the author's advice...

Avatar

I was wondering when someone was going to mention that, and how much weight should be given to the author's advice...