I wonder if anyone could help me with this.
In normal circumstances, re-rendering a form fields with validation
errors, show original entered data and not type_cast data from the
However, I have a situation where I am submitting a number of values
to do a bulk update. My model converts the returned values and does
the necessary processing, building the data structure from the request
However, when I use this to re-display the form using render :action,
the values I get are the ones after type_cast. ie. 'x' entered for
numeric becomes 0
I know from my unit tests that the model has built my object with the
correct associations, and the objects with validation errors are still
shown as new_record and the attribute_before_validation is there as
entered by the user.
So I am wondering what Rails uses to determine how to redisplay the
fields (I had assumed that it checked for new_record and used
attribute_before_validation). But this does not seem to be the case
I can only think that it is done from the params hash. Now in my
case, the input fields do not follow the conventional object name
derivation, but the naming would be consistent with the params hash.
The only reason I can come up with at the moment for the post
validation values being shown is that Rails does some sort of cross
reference between the input field name values, the params hash and the
object values. Which I have made not consistent