samedi 7 juin 2014

How to display validation error messages with Simple_form but without model?


Vote count:

0




I use Simple_form in my Rails 4 application.


How can I display error messages in a view that is not tied to a model ?


I want to have the same result than in other views based on models.


For now, this is the code in the view :



<%= simple_form_for(:registration, html: { role: 'form' }, :url => registrations_path) do |f| %>

<%= f.error_notification %>

<%= f.input :name, :required => true, :autofocus => true %>
<%= f.input :email, :required => true %>
<%= f.input :password, :required => true %>
<%= f.input :password_confirmation, :required => true %>

<%= f.button :submit %>

<% end %>


In a 'normal' view (i.e. with a model) the line <%= f.error_notification %> display errors.


What should I do in my controller to initialize something used by Simple_form to display errors ?


Thanks



asked 17 secs ago






Aucun commentaire:

Enregistrer un commentaire