I've been struggling with this for a while now...
I have a more complex form (saves one transaction and two transaction_data at the same time).
I got it to save all right, however I am struggling with the handling of errors. If I use the following in "create" - in case of an error - it doesn't hold any of the values I've had on the same page before the submit and basically ends in rails error.
if @transac.save
...
else
...
format.html { render :action => 'buy' }
end
Also in "buy" (in the controller) before I submit the form I've had stuff like:
@transac = Transac.new
2.times { @transac.transaction_datas.build }
@my_collection = current_user.items.all
The problem is that in case of an error Rails doesn't run the Controller action "buy", but only its view. How can I handle this? I need @my_collection to display the list of radio-button elements the user would pick from in case of an error?!