[Rails] symbol pointing to a method idiom in ror model

2010-01-22 Thread Hiro Protagonist
IN NEED OF EXPLANATION: class Comment < ActiveRecord::Base validate :must_be_friends def must_be_friends errors.add_to_base("Must be friends to leave a comment") unless commenter.friend_of?(commentee) end end The above code comes from rails documentation. Ther

[Rails] Re: do not understand collect method use wit property

2009-03-11 Thread Hiro Protagonist
doing @foo.map(&:id) doesn't perform as well as @foo.map { |f| > f.id } for big numbers of foos... > Also note that this is a Rails only feature (ie: try it on plain irb > and it will not work). > > On Mar 11, 1:35�pm, Hiro Protagonist http://www.ruby-forum.com/. --~--~---

[Rails] do not understand collect method use wit property

2009-03-11 Thread Hiro Protagonist
Hi all, Can someone explain to me in terms of ruby why this works? Story.find_all_by_user_id(2).collect(&:link)# 1 method call This is in ROR console. link is a property of Story. The above command finds all db rows and all their properties (columns) with user_id == 2 and creates an array