ruby on rails - simple_form not displaying error -
my first time posting here!
i have form, lot fields , it's working great unless validation error occurs...
if "validates_presence_of" raised, "activerecord::recordinvalid in ..." page opened , leaves form...
how can errors shown on same page/form (as always)?
all best!
my controller
if check_cadastro == "vĂ¡lido para cadastro" code.... if @usuario.save! session[:usuario_id] = @usuario.id cookies[:token] = @usuario.token render :action => "edit" else render "new" end end my view
<%= simple_form_for @usuario |f| %> <%= f.error_notification %> <div ><%= f.input :cnpj, input_html: { class: 'txt' } , :label => false %></div> <div ><%= f.input :razaosocial, input_html: { class: 'txt' } , :label => false %></div> <% end %>
you should call save instead of save! if statement can fail, object contain messages in errors object, , simple_form can render them next each form input after render :new.
Comments
Post a Comment