To set up validation inside the model in Rails, I have to write something like:
class Post < ActiveRecord::Base validates :name, :presence => true validates :title, :presence => true, :length => { :minimum => 5 } end
I canβt understand how this works. It looks like he is calling a method called validates and passing parameters, but this cannot be, because, I believe, I can not call the method directly in the body of the class.
So what is really going on here?
Update
From the answers, it seems that this is a method call from an inhereted Base class, but then why does this not work ?:
class Parent def foo puts "called foo" end end class Child < Parent foo foo end
source share