form_for error messages in Ruby on Rails

前端 未结 4 863
离开以前
离开以前 2020-12-10 12:28

What is the preferred way to display validation error messages using form_for in Rails 4?

<%= form_for @post do |f| %>
  ...
<% end %&g         


        
4条回答
  •  情深已故
    2020-12-10 13:08

    Same as Rails 3 -- see f.error_messages in Rails 3.0 or http://railscasts.com/episodes/211-validations-in-rails-3 for many different possibilities.

    My personal preference is to use simple_form and have it put the error next to the input.

提交回复
热议问题