This project is archived and is in readonly mode.

#3274 ✓stale
Joe Van Dyk

When an ActiveRecord has a column named 'field', bad behavior happens

Reported by Joe Van Dyk | September 27th, 2009 @ 12:56 AM

I've attached a patch showing the broken test.

If Blarg has a string column named 'field', creating a Blarg instance results in the following:

@@@>> a = Blarg.new => #

a.field = {:elad => 'elad'} ArgumentError: wrong number of arguments (4 for 1)

from /Users/eladmeidar/projects/bugmash/vendor/rails/activerecord/lib/../../activemodel/lib/active_model/attribute_methods.rb:147:in attribute_changed?'<br/> from /Users/eladmeidar/projects/bugmash/vendor/rails/activerecord/lib/../../activemodel/lib/active_model/attribute_methods.rb:147:insend'
from /Users/eladmeidar/projects/bugmash/vendor/rails/activerecord/lib/../../activemodel/lib/active_model/attribute_methods.rb:147:in field_changed?'<br/> from /Users/eladmeidar/projects/bugmash/vendor/rails/activerecord/lib/active_record/attribute_methods/dirty.rb:153:inwrite_attribute'
from /Users/eladmeidar/projects/bugmash/vendor/rails/activerecord/lib/active_record/attribute_methods/write.rb:13:in field='<br/> from /Users/eladmeidar/projects/bugmash/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:35:insend'
from /Users/eladmeidar/projects/bugmash/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:35:in method_missing'<br/> from (irb):3 @@@

Comments and changes to this ticket

  • Joe Van Dyk

    Joe Van Dyk September 27th, 2009 @ 12:57 AM

    Ouch, thought I formatted it correctly.

  • Joe Van Dyk

    Joe Van Dyk September 27th, 2009 @ 01:08 AM

    I've attached a patch that includes the broken test and fixes the issue.

  • Joe Van Dyk

    Joe Van Dyk September 27th, 2009 @ 01:09 AM

    Ooops, bad patch. Better one attached.

  • Joe Van Dyk

    Joe Van Dyk September 27th, 2009 @ 01:11 AM

    • Tag changed from 3, activerecord to 3, activerecord, patch
  • Elad Meidar

    Elad Meidar September 27th, 2009 @ 04:09 AM

    +1 verified and applies cleanly on Master, tests pass as well... also, this may probably lead to also closing down #1742

  • cohitre
  • rbxbx

    rbxbx September 27th, 2009 @ 05:04 AM

    was getting this failure:

      1) Failure:
    test_should_allow_except_option_for_list_of_authors(DatabaseConnectedJsonEncodingTest)

    [./test/cases/json_serialization_test.rb:179:in `test_should_allow_except_option_for_list_of_authors'
     ./test/cases/../../lib/../../activemodel/lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in `__send__'
     ./test/cases/../../lib/../../activemodel/lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in `run']:
    
    
    
    
    <"[{&quot;id&quot;:1},{&quot;id&quot;:2}]"> expected but was <"[{&quot;id&quot;:1,&quot;field&quot;:null},{&quot;id&quot;:2,&quot;field&quot;:null}]">.
    attached patch corrects on master.
  • rbxbx

    rbxbx September 27th, 2009 @ 05:08 AM

    • Tag changed from 3, activerecord, patch to 3, activerecord, bugmash, patch
  • sr.iniv.t

    sr.iniv.t September 27th, 2009 @ 07:03 PM

    +1 on rbxbx's patch (applies cleanly on master and all tests pass). Joe's patch applies, but the test test_should_allow_except_option_for_list_of_authors fails for me.

  • Rizwan Reza

    Rizwan Reza January 18th, 2010 @ 01:09 PM

    • Assigned user set to “Pratik”
  • Rizwan Reza

    Rizwan Reza January 18th, 2010 @ 01:29 PM

    • Tag changed from 3, activerecord, bugmash, patch to 3, 3.0, activerecord, bugmash, patch

    I can confirm this error still exists.

    +1 verified.

    The patch by rbxbx applies cleanly.

  • Rizwan Reza

    Rizwan Reza February 12th, 2010 @ 12:46 PM

    • Tag changed from 3, 3.0, activerecord, bugmash, patch to 3, 3.0, activerecord, patch
  • Ryan Bigg

    Ryan Bigg October 11th, 2010 @ 02:08 AM

    • State changed from “new” to “open”
    • Tag changed from 3, 3.0, activerecord, patch to 3.0, activerecord, patch
    • Importance changed from “” to “”

    Does this error still exist guys?

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:30 PM

    • Tag changed from 3.0, activerecord, patch to 30, activerecord, patch

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:30 PM

    • State changed from “open” to “stale”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages