This project is archived and is in readonly mode.
fields_for with nested attributes association should accept explicitly passed objects
-
Pascal Ehlert
Should have mentioned that this only applies for one-to-one associations..
-
Eloy Duran
+1 Applies clean, tests run and looks good to me.
-
Michael Koziarski
Wouldn't this only work with ActiveRecord objects? Not sure if that's a deal breaker here, but seems like we should be able to work with it another way.
-
Pascal Ehlert
That's true, it works for all objects that respond to "new_record?"..
You may have noticed that I've been inspired by the existing code here which is why I thought it would be a reasonable assumption.
I didn't like this too much myself, but I think in order to work with form helpers, attributes should have a #new_record? method anyway.
Maybe we can just put a note somewhere in the rdoc of form_for?
-
Eloy Duran
@Michael: Well ActiveRecord and DataMapper and any objecty which responds to new_record?. (The same kind of stuff happens on line 261 btw.)
It's not a deal breaker though, we need an ID for new records as well. So since we are already assuming the new_record? method, I chose to use that to check if an object is a record or not.
-
Repository
- State changed from new to committed
(from [d15d53cf810014b90827015ecd0e601176492fb7]) Allowing an object to be passed explicitly to a fields_for with nested_attributes on one-to-one associations
Signed-off-by: Michael Koziarski michael@koziarski.com [#1849 fields_for with nested attributes association should accept explicitly passed... state:committed] http://github.com/rails/rails/co...
