Skip to content

Loading…

AR type casting: undefined method `to_i' for true:TrueClass #8067

Closed
mperham opened this Issue · 5 comments

2 participants

@mperham

This is a regression in 3-2-stable. Code works fine in 3.2.6.

   undefined method `to_i' for true:TrueClass
 # /Users/mperham/src/rails/activerecord/lib/active_record/connection_adapters/column.rb:78:in `type_cast'
 # /Users/mperham/src/rails/activerecord/lib/active_record/attribute_methods/dirty.rb:86:in `_field_changed?'
 # /Users/mperham/src/rails/activerecord/lib/active_record/attribute_methods/dirty.rb:63:in `write_attribute'
 # /Users/mperham/src/rails/activerecord/lib/active_record/attribute_methods/write.rb:14:in `admin='
@rafaelfranca
Ruby on Rails member

Related with #7509 and #6092

@rafaelfranca
Ruby on Rails member

@mperham is possible to you change this column from :integer to :boolean? I think this is causing your issue.

@rafaelfranca
Ruby on Rails member

@mperham actually I'm reverting thiagopradi@652107e

Thank you so much to test it

@mperham

Thanks, let me know when the revert lands on 3-2-stable and I'll restart my test suite.

@rafaelfranca rafaelfranca added a commit that closed this issue
@rafaelfranca rafaelfranca Fix bug when Column is trying to type cast boolean values to integer.
This can occur if the user is using :integer columns to store boolean
values. Now we are handling the boolean values but it still raises if
the value can't type cast to integer and is not a boolean. See #7509.

Fixes #8067.
96a13fc
@rafaelfranca
Ruby on Rails member

Done.

@rafaelfranca rafaelfranca added a commit that referenced this issue
@rafaelfranca rafaelfranca Fix bug when Column is trying to type cast boolean values to integer.
This can occur if the user is using :integer columns to store boolean
values. Now we are handling the boolean values but it still raises if
the value can't type cast to integer and is not a boolean. See #7509.

Fixes #8067.

Conflicts:
	activerecord/CHANGELOG.md
3525a9b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.