1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test/schema
Godfrey Chan 788bb40e38 Building new records with enum scopes now works as expected
Previously, this would give an `ArgumentError`:

   class Issue < ActiveRecord::Base
     enum :status, [:open, :finished]
   end

   Issue.open.build # => ArgumentError: '0' is not a valid status
   Issue.open.create # => ArgumentError: '0' is not a valid status

PR #13542 muted the error, but the issue remains. This commit fixes
the issue by allowing the enum value to be written directly via the
setter:

   Issue.new.status = 0 # This now sets status to :open

Assigning a value directly via the setter like this is not part of the
documented public API, so users should not rely on this behavior.

Closes #13530.
2014-01-03 09:31:01 -08:00
..
mysql2_specific_schema.rb fix detect column type of enum 2013-04-01 17:09:20 +09:00
mysql_specific_schema.rb fix detect column type of enum 2013-04-01 17:09:20 +09:00
oracle_specific_schema.rb Do not create synonym named subjects 2013-11-27 23:43:51 +01:00
postgresql_specific_schema.rb extract PG range tests from datatype_test.rb into range_test.rb 2013-12-13 14:17:21 +01:00
schema.rb Building new records with enum scopes now works as expected 2014-01-03 09:31:01 -08:00
sqlite_specific_schema.rb Remove sqlite specificsupports_autoincrement? which always defaults to true 2013-08-10 22:21:25 +05:30