#55 ✓resolved
andyw8

FIX: Error when using conditions with belongs_to

Reported by andyw8 | July 13th, 2008 @ 12:05 AM | in Hobo 0.8

Example:

belongs_to :group, :conditions => "1=1"

Fails with:

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.interpolate_sql

See also: http://hobocentral.net/forum/viewtopic.php?t=4241

Comments and changes to this ticket

  • Tom Locke

    Tom Locke July 29th, 2008 @ 11:11 AM

    • Assigned user set to “Tom Locke”
    • State changed from “new” to “investigating”
  • Tom Locke

    Tom Locke August 5th, 2008 @ 11:38 AM

    • Tag set to defect, models
    • Milestone set to Hobo 0.8
  • Matt Jones

    Matt Jones August 8th, 2008 @ 11:23 AM

    • Title changed from “Error when using conditions with belongs_to” to “FIX: Error when using conditions with belongs_to”

    Change line 280 in rapid_forms.dryml from:

    conditions = ActiveRecord::Associations::BelongsToAssociation.new(this, thisfieldreflection).conditions

    to

    conditions = ActiveRecord::Associations::BelongsToAssociation.new(thisparent, thisfield_reflection).conditions

    AR:Associations::BelongsToAssociation expects the object defining belongs_to in the first argument.

    It also took a while to figure out what :conditions on a belongs_to was for; some documentation would be nice...

    See also this post, for some interesting uses for this: http://www.dweebd.com/ruby/has_m...

    --Matt

  • Tom Locke

    Tom Locke August 19th, 2008 @ 11:48 AM

    • State changed from “investigating” to “resolved”

    Confirmed and fixed in 389cd72110d86a43470b2a0656af11457e498e6a.

    Thanks for the fix.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

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

People watching this ticket

Tags

Pages