Reputation: 6121
I have resources :campaigns
defined in routes.rb.
If I create a form_for @campaign
in /campaigns/new.html.erb (campaigns#new), create appropriate fields, and then submit it if there's an error saving the model in campaigns#create
, if I redirect the browser back to the campaigns#new
, the form fields appear empty.
I remember there being some trick to it, but I can't seem to Google it because I'm weak on nomenclature.
Upvotes: 1
Views: 142
Reputation: 16730
In your create action instead of redirecting just render the 'new' page so your @campaign value is set when rendering the form.
Upvotes: 3