class method self.new

Ruby on Rails 3.0.20

Since v2.2.3 Last seen in v3.0.20

Available in: v2.2.3 v2.3.18 v3.0.20

Signature

self.new(name, default, sql_type = nil, null = true)

Instantiates a new column in the table.

name is the column’s name, such as supplier_id in supplier_id int(11). default is the type-casted default value, such as new in sales_stage varchar(20) default 'new'. sql_type is used to extract the column’s length, if necessary. For example 60 in company_name varchar(60). It will be mapped to one of the standard Rails SQL types in the type attribute. null determines if this column allows NULL values.

Parameters

name req
default req
sql_type opt = nil
null opt = true
Source
# File activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb, line 30
      def initialize(name, default, sql_type = nil, null = true)
        @name, @sql_type, @null = name, sql_type, null
        @limit, @precision, @scale = extract_limit(sql_type), extract_precision(sql_type), extract_scale(sql_type)
        @type = simplified_type(sql_type)
        @default = extract_default(default)

        @primary = nil
      end

Defined in activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb line 30 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::ConnectionAdapters::Column

Type at least 2 characters to search.

↑↓ navigate · open · esc close