Last Updated: February 25, 2016
·
1.61K
· stevennunez

View source in irb

You can view the source of any method written in ruby in Rails Console with:

Post.method(:create).source

=>def create(attributes = nil, options = {}, &block)
    if attributes.is_a?(Array)
      attributes.collect { |attr| create(attr, options, &block) }
    else
      object = new(attributes, options, &block)
      object.save
      object
    end
  end