After validation, I got an error and I got returned back to :action => :new
. Some field on form already filled, so I want to keep them filled even after error message too. How it can be done?
Your View (new.html.erb) something like following
<%= error_message_for :user %> <% form_for :user, :action=>"create" do|f|%> <%= f.text_field :login %> <% end %>
Controller Code (create method)
def create @user=User.new(params[:user]) if @user.save redirect_to :action=>'index' else render :action=>'new' #you should render to fill fields after error message end end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With