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. There is a similar
example inAgile Web Development with Rails by Dave Thomas and Sam Ruby.
my understanding is that:
validate :must_be_friends
is a method call to the validate method within the ActiveRecord::Base
class. Supposedly it's contents are:
def validate
end
This of course does not work with ruby because the validate method does
not take parameters.
Is metaporgramming being used? Tnis seems like some sort of Rails
idiom.
Please explain.
I'm trying to get back into Rails after my first attempt.
TIA,
Pete
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.