未定义的方法`每个'为零:NilClass不工作

时间:2018-06-04 15:06:06

标签: ruby methods undefined each embedded-ruby

我知道有人问过这个问题。我查看了过去一小时我能找到的每一个回复。我需要有人查看我的代码,看看我错过了什么。

-Controller.erb

class RidersController < ApplicationController


def index
    @riders = Rider.all
    @rider = Rider.new

  end

  def new
    @rider = Rider.new
  end

  def create
    @rider = Rider.new(rider_params)

    if @rider.save
      flash[:success] = "You have successfully created a new Rider!"
      redirect_to @rider
    else
      render :new
    end
  end

  def show
    @rider = Rider.find(params[:id])
  end

  def rider_params
    params.require(:rider).permit(:RRCW, :DFN, :DLN, :DMA, :DC, :DS, :DZ, :DCP, :DEA, :ECFN, :ECLN, :ECCP, :ECT, :ExpLev, :RD, :FLH, :FLT, :SLH, :SLT, :DTS, :PT)
  end
end

-Show.html.erb

<% title "Thank You for Registring" %>
<div class="row">
  <div class="col-10">
    <div class="table-responsive">
      <table class="table">
        <tr>
          <th>Rider ID</th>
          <th>Driver Name:</th>
        </tr>
        <% @riders.each do |r| %>
          <tr>
            <td><%= r.id %></td>
            <td><%= r.DFN %></td>
          </tr>
        <% end %>
      </table>
    </div>
  </div>
</div>

我似乎无法将我的数据库存储到要显示的记录中。是的,DB中有信息,我查了一下

0 个答案:

没有答案