This project is archived and is in readonly mode.

#3661 ✓stale
Paul Sadauskas (Rando)

#fields_for always expects a model

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

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

Comments and changes to this ticket

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

Pages