Just another OOPL class Book extends ActiveRecord\Model { static $belongs_to = array( array('bookstand') ); static $validates_presence_of = array( array('name') ); public static function done() {} public function is_recent() {} }
Concern module M extend ActiveSupport::Concern included do scope :foo, :conditions => {:created_at => nil} end module ClassMethods def cm; puts 'I am a class method'; end end module InstanceMethods def im; puts 'I am an instance method'; end end end
How to use class Controller < ApplicationController before_action :auth, :unless => :logged_in? end class Model < ActiveRecord::Base before_validation do normalize_attributes end end ※ :unless keyword is allowed from ActiveSupport::Callbacks 4.0