I got the following example from http://guides.rubyonrails.org/getting_started.html
models/post.rb
class Post < ActiveRecord::Base
validates :name, :presence => true
validates :title, :presence => true,
:length => { :minimum => 5 }
end
but it doesn’t work
NoMethodError in PostsController#index
undefined method `validates' for #<Class:0x7f1fd7b6d750>
It was a version issue. Installing Rails 3 solved the problem.