I have set up a custom Rails new action (to hack around a particular solution) which works fine but there is a problem when there is an error in the form and I need to capture the previous values in the edit action.
So the question is, on an unsuccessful creation, how can I capture the parameters and plug these back into the edit view?
Form action:
def go
begin
@quote = Quote.new
@quote.create_with_custom_params(params)
@quote.save!
rescue Exception => ex
flash[:error] = "an error occured"
render :action => "edit"
end
end
Form view (minimised):
<%= form_tag :controller => :quoter, :action => :go do %>
<%= text_field_tag :name, nil, :placeholder => "quote name" %>
<%= submit_tag "Save quotation" %>
<% end %>
Instead of:
use: