views:

114

answers:

1

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?!

+1  A: 

Are you sure transaction (or even get??) isn't a reserved word?

floyd
I got rid of "transaction" and "get", but still the same problem, and it seems to be related to the fact that Rails doesn't run the Controller action "get"... So how do I handle this?! So frustrating!
Chris F.
If you are still having a problem with a controller action named get, why not change the name of that action (the Rails convention would probably be 'show'). Also, post your latest code, because the code in your answer still shows a model named 'Transaction' as well...
floyd
floyd, I updated the code in the question...
Chris F.