Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #8983 (reopened defect)

Opened 3 years ago

Last modified 1 year ago

[PATCH] date_select stack dump for virtual field

Reported by: ammulder Assigned to: core
Priority: high Milestone:
Component: ActiveRecord Version: edge
Severity: major Keywords:
Cc:

Description

I have an ActiveRecord class with a virtual date field. Which is to say, I've defined a birthday method and a birthday= method, but the date is actually stored in a different format in the table so there's no actual "birthday" column.

I used a date_select with attribute name "birthday" and I get the stack trace below. I guess it's not obvious what the data type of that virtual field is. So first, I wish it game a more useful error than nil.klass (something like 'I can't figure out the data type of field 'birthday', please use ... to specify it'). And second, I wish there was a way for me to specify the data type somehow, or that date_select could somehow automatically indicate that the data type is Time.

Thanks,

Aaron

NoMethodError (You have a nil object when you didn't expect it!
The error occurred while evaluating nil.klass):
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:2082:in `execute_callstack_for_multiparameter_attributes'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:2081:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:2081:in `execute_callstack_for_multiparameter_attributes'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:2074:in `assign_multiparameter_attributes'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1675:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1591:in `update_attributes'
...

Attachments

date_select_for_virtual_field_fixed.diff (0.7 kB) - added by sur on 08/04/07 19:24:50.
now you can use the date_select with a virtual field

Change History

07/14/07 22:33:57 changed by lifofifo

  • status changed from new to closed.
  • resolution set to incomplete.

Please attach tests/patch. Check PatchRequirements for more details.

07/15/07 01:33:25 changed by ammulder

I'm sorry -- your policy is not to fix bugs unless the reporter provides the fix? No thanks...

07/15/07 01:35:38 changed by lifofifo

  • status changed from closed to reopened.
  • resolution deleted.

08/04/07 18:19:04 changed by sur

@ammulder: If you have liked rails, then u must have liked the Test Driven Development of rails as well. Thats what lifofifo was asking you to provide a test case(note that which will also be a patch) justifying the Bug but not the fix per se.

08/04/07 18:57:28 changed by sur

  • summary changed from date_select stack dump for virtual field to [PATCH] date_select stack dump for virtual field.

Its a patch for the file "activerecord/lib/active_record/base.rb". Apply this patch and you can use the date_select for a virtual field.

08/04/07 19:24:50 changed by sur

  • attachment date_select_for_virtual_field_fixed.diff added.

now you can use the date_select with a virtual field

01/03/08 23:17:04 changed by thorny_sun

i can confirm same exact behavior in 2.0.2--- why can't this fix be folded into the core?

01/03/08 23:18:20 changed by thorny_sun

  • priority changed from normal to high.
  • version changed from 1.2.3 to edge.
  • severity changed from normal to major.

03/30/08 16:06:32 changed by zach-inglis-lt3

Happening for me too.

Any updaters, Core?

11/17/08 11:43:48 changed by lamyseba

Happenning for me too in 2.0.2. Is this fixed in later versions?