Topic: Is this a method call?

Hi, I was reading ROR tutorial and can't figure out this piece of code:

class Post < ActiveRecord::Base
  validates :name, :presence => true
  validates :title, :presence => true,
                    :length => { :minimum => 5}

I understand class declaration, inheritance, but "validates" is what's bugging me. I know what it is supposed to do inside rails but  what is it? Is it a method call? Why isn't it inside another method? How it works and what's passed as argument to it?

Thanks smile

Last edited by dabrorius (2011-01-02 21:07:32)

Re: Is this a method call?

Yes it is a method call: you're calling a class method so you can think of it as a shorthand way of saying:

Post.validates(:name, :presence => true)
Rob Anderton

Re: Is this a method call?

thanks, it's quite obvious actually, I was just sleepy and confused smile