title: How to show error message on rails views?
body: <p>I am newbie in <code>rails</code> and want to apply validation on <code>form</code> fields.</p>
  
  <p>myviewsnew.html.erb</p>
  
  <pre><code>&lt;%= form_for :simulation, url: simulations_path do |f|  %&gt;
  
  &lt;div class="form-group"&gt;
    &lt;%= f.label :Row %&gt;
    &lt;div class="row"&gt;
      &lt;div class="col-sm-2"&gt;
        &lt;%= f.text_field :row, class: 'form-control' %&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  .....
  </code></pre>
  
  <p>Simulation.rb</p>
  
  <pre><code>class Simulation &lt; ActiveRecord::Base
   belongs_to :user
   validates :row, :inclusion =&gt; { :in =&gt; 1..25, :message =&gt; 'The row must be between 1 and 25' }
  end
  </code></pre>
  
  <p>simulation_controller.rb</p>
  
  <pre><code>class SimulationsController &lt; ApplicationController
  
    def index
      @simulations = Simulation.all
    end
  
    def new
    end
  
    def create
      @simulation = Simulation.new(simulation_params)
      @simulation.save
      redirect_to @simulation
    end
  
    private
     def simulation_params
     params.require(:simulation).permit(:row)
    end
  </code></pre>
  
  <p>I want to check the integer range of <code>row</code> field in model class and return the error message if it's not in the range. I can check the range from above code but not able to return the error message</p>
  
  <p>Thanks in advance</p>