Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Fixture named accessors do not work when the fixture name is not the table name

#124

If you have a fixture name which does not match the table name for the associated model, the fixture named accessors will raise an exception like this:

NoMethodError: undefined method `[]' for nil:NilClass

The underlying cause is similar to ticket #8 Fixture caching does not work with prefixed/suffixed tables: @loaded_fixtures has values stored in it using the table name, but loaded using the fixture name. The attached patch (with test) fixes this.

(The test case is simpler than a real-life situation, but illustrates the problem. A real-life situation might involve prefixed/suffixed tables or tables in different schemas.)

Reported by Rhett Sutphin · May 6th, 2008 @ 05:05 PM

State: resolved
Milestone: none
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Pratik
    Pratik
    • State changed from new to incomplete
    • Assigned user set to Pratik

    Can you please rewrite the patch to use an existing table instead of creating a new table ?

    Rest looks fine.

    Thanks!

    May 19th, 2008 @ 11:09 AM

  2. Rhett Sutphin
  3. Rhett Sutphin
    Rhett Sutphin

    Updated test to use existing table with a different model. Thanks for your review.

    May 22nd, 2008 @ 03:37 AM

  4. Pratik
    Pratik
    • State changed from incomplete to open

    May 21st, 2008 @ 11:17 PM

  5. Rhett Sutphin
    Rhett Sutphin
    • State changed from open to incomplete

    The last change on this ticket indicates it went from incomplete to open, but the ticket summary still says "incomplete" and it is not showing up on the "open patches" report.

    This is just a ping so that it doesn't get lost.

    June 4th, 2008 @ 03:00 AM

  6. Pratik
    Pratik
    • State changed from incomplete to open
    • Tag set to activerecord, bug, fixtures, patch

    July 7th, 2008 @ 11:29 AM

  7. Repository
    Repository
    • State changed from open to resolved

    (from [d72c66532f959846cdc2d7fb1dc1ef6ba87bdcb1]) Make fixture accessors work when fixture name is not same as the table name. [#124 state:resolved]

    Signed-off-by: Pratik Naik

    http://github.com/rails/rails/co...

    July 14th, 2008 @ 02:04 AM