firstdraft / draft_generators

Rails generators that help beginners learn to program.
MIT License
2 stars 3 forks source link

Pm validation messages #99

Closed pmckernin closed 4 years ago

pmckernin commented 4 years ago

I added the code of .errors.full_messages.to_sentence to the create and update actions in the draft:account authentication_controller.

To test, go to the snapshot below. I have already run the draft:account command. If you go to /user_sign_up and add the same user twice it will show a message, then if you go to sign_in and try to sign in with a bad password you should get a different message. To be clear, I have have already gone to the application.html layout page and placed code to make the messages visible.

Open in Gitpod

jelaniwoods commented 4 years ago

@pmckernin LGTM!

One thing I notice is that the default error messages will use the model name, which is not always the best UX I think.

For example, a model like regional_manager the default error messages will be something like:

Screen Shot 2020-08-19 at 7 07 48 PM

Which is different than what happens on the update error page.

Screen Shot 2020-08-19 at 7 06 40 PM
  <% if @regional_manager.errors.any? %>
  <% @regional_manager.errors.full_messages.each do |message| %>
    <div class="alert">
      <%= message %>
    </div>
  <% end %>
  <% end %>

but maybe that is a change for a different PR.

raghubetina commented 4 years ago

@pmckernin LGTM