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.

#fields_for always expects a model

#3661

I have a case where I have a hash object as a property of a alternative-ORM model, which I want to make form fields for. Using the fields_for helper almost works, except in one case, where it attempts to call #new_record? on the hash. Attached is a patch to check for the method first, and it works great.

As an example, the model I'm trying to construct fields for is generated like this:

def build_metric_filter
  @metric_filter = MetricFilter.new
  @metric_filter.criteria = [{:target => "Hostname", :comparison => "is", :pattern => ""}]
  @metric_filter
end

Reported by Paul Sadauskas (Rando) · January 5th, 2010 @ 07:28 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Paul Sadauskas (Rando)
  2. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to stale
    • Importance changed from to Low

    Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.

    October 8th, 2010 @ 12:05 PM