title: Rails 5.2.3 - Validation errors are displayed in console but are not passed to the view
body: <p>When I submit a form with blank fields that are required I see the <code>ROLLBACK</code> and <code>ActiveModel::Errors</code> in the console but for some reason I can't render the errors in the view.</p>
  
  <p>This is happening on both the <code>new</code> and <code>edit</code> templates.
  Needless to say, creating a new record or editing an existing one with the required fields works fine.</p>
  
  <p>This is what my code looks like:</p>
  
  <p>Model: <strong>transactions.rb</strong></p>
  
  <pre class="lang-rb prettyprint-override"><code>class Transaction &lt; ApplicationRecord
    belongs_to :account
    belongs_to :category
  
    validates :date, :description, :amount, :category_id, :account_id, presence: true
  end
  </code></pre>
  
  <p>Controller: <strong>transactions_controller.rb</strong></p>
  
  <pre class="lang-rb prettyprint-override"><code> def new
      @transaction = Transaction.new
    end
  
    def create
      @transaction = Transaction.create(transaction_params)
  
      if @transaction.save
        redirect_to account_path(@account), notice: "Transaction created"
      else
        render :new
      end
    end
  
    def edit
      if @transaction.amount &gt; 0
        @transaction_type = "income"
      else
        @transaction_type = "expense"
      end
  
      render :edit
    end
  
    def update
      if @transaction.update(transaction_params)
        redirect_to account_path(@account)
      else
        render :edit
      end
    end
  
    private
      def transaction_params
        params.require(:transaction).permit(:date, :description, :amount, :category_id, :account_id)
      end
  </code></pre>
  
  <p>View: <strong>new.html.erb</strong> (or <strong>edit.html.erb</strong>)</p>
  
  <pre class="lang-rb prettyprint-override"><code>  &lt;ul&gt;
      &lt;% @transaction.errors.full_messages.each do |message| %&gt;
        &lt;li&gt;&lt;%= message %&gt;&lt;/li&gt;
      &lt;% end %&gt;
    &lt;/ul&gt;
  </code></pre>
  
  <p><strong>Log</strong> after submitting the form:</p>
  
  <pre><code>Started POST "/accounts/15/transactions" for 192.168.55.1 at 2019-09-07 03:00:24 +0000
  Cannot render console from 192.168.55.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
  Processing by TransactionsController#create as JS
    Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"CJd+/rB6LcUqQAz0ZvY0cf8Dcu+2qzUYLCQHLWE2GElZtJrKbKq2EODFeVvKG6NkE2MxtIIjRreqHAnKu2sJ9A==", "transaction"=&gt;{"date(1i)"=&gt;"2019", "date(2i)"=&gt;"9", "date(3i)"=&gt;"7", "description"=&gt;"", "category_id"=&gt;"1", "amount"=&gt;"0"}, "transaction_type"=&gt;"Expense", "commit"=&gt;"Add Transaction", "account_id"=&gt;"15"}
    User Load (0.2ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["id", 1], ["LIMIT", 1]]
    ↳ /var/lib/gems/2.6.0/gems/activerecord-5.2.3/lib/active_record/log_subscriber.rb:98
    Account Load (0.1ms)  SELECT  "accounts".* FROM "accounts" WHERE "accounts"."id" = $1 LIMIT $2  [["id", 15], ["LIMIT", 1]]
    ↳ app/controllers/transactions_controller.rb:64
     (0.1ms)  BEGIN
    ↳ app/controllers/transactions_controller.rb:24
    Category Load (0.2ms)  SELECT  "categories".* FROM "categories" WHERE "categories"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]
    ↳ app/controllers/transactions_controller.rb:24
     (0.2ms)  ROLLBACK
    ↳ app/controllers/transactions_controller.rb:24
     (0.1ms)  BEGIN
    ↳ app/controllers/transactions_controller.rb:26
     (0.1ms)  ROLLBACK
    ↳ app/controllers/transactions_controller.rb:26
    Rendering transactions/new.html.erb within layouts/application
  </code></pre>
  
  <p>If I add <code>p @transaction.errors</code> in the <code>create</code> method or go into the Rails console and run <code>@transaction.errors</code> I do get the errors:</p>
  
  <pre><code>irb(main):026:0&gt; @transaction.errors
  =&gt; #&lt;ActiveModel::Errors:0x0000000006447158 @base=#&lt;Transaction id: nil, date: nil, description: nil, amount: nil, account_id: nil, created_at: nil, updated_at: nil, category_id: 
  nil&gt;, @messages={:account=&gt;["must exist", "can't be blank"], :category=&gt;["must exist", "can't be blank"], :date=&gt;["can't be blank"], :description=&gt;["can't be blank"], :amount=&gt;["can't be blank"]}, @details={:account=&gt;[{:error=&gt;:blank}, {:error=&gt;:blank}], :category=&gt;[{:error=&gt;:blank}, {:error=&gt;:blank}], :date=&gt;[{:error=&gt;:blank}], :description=&gt;[{:error=&gt;:blank}], :amount=&gt;[{:error=&gt;:blank}]}&gt;
  </code></pre>
  
  <p>Something else I tried is adding these 2 lines to the <strong>new.html.erb</strong>:</p>
  
  <p><code>&lt;%= @transaction.errors %&gt;</code> renders: <code>#&lt;ActiveModel::Errors:0x00007ff650570500&gt;</code></p>
  
  <p><code>&lt;%= @transaction.errors.full_messages %&gt;</code> renders: <code>[]</code></p>