diff options
author | Alan Wu <XrXr@users.noreply.github.com> | 2019-03-20 12:20:51 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2019-03-20 15:05:31 -0400 |
commit | 15b11ce505b9e94031c640d8488d6237f860d08b (patch) | |
tree | 9c6c79654c24b00b783d292c89214c7858dbf675 /activerecord/lib | |
parent | c11d115fa3c58ec6bde5e9799673cee381d22d47 (diff) | |
download | rails-15b11ce505b9e94031c640d8488d6237f860d08b.tar.gz rails-15b11ce505b9e94031c640d8488d6237f860d08b.tar.bz2 rails-15b11ce505b9e94031c640d8488d6237f860d08b.zip |
Document option forwarding in ActiveRecord::Base.attribute
This has been supported for a while but we didn't have documentation
for it.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/attributes.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/attributes.rb b/activerecord/lib/active_record/attributes.rb index 35150889d9..7cf421c184 100644 --- a/activerecord/lib/active_record/attributes.rb +++ b/activerecord/lib/active_record/attributes.rb @@ -41,6 +41,9 @@ module ActiveRecord # +range+ (PostgreSQL only) specifies that the type should be a range (see the # examples below). # + # When using a symbol for +cast_type+, extra options are forwarded to the + # constructor of the type object. + # # ==== Examples # # The type detected by Active Record can be overridden. @@ -112,6 +115,16 @@ module ActiveRecord # my_float_range: 1.0..3.5 # } # + # Passing options to the type constructor + # + # # app/models/my_model.rb + # class MyModel < ActiveRecord::Base + # attribute :small_int, :integer, limit: 2 + # end + # + # MyModel.create(small_int: 65537) + # # => Error: 65537 is out of range for the limit of two bytes + # # ==== Creating Custom Types # # Users may also define their own custom types, as long as they respond |