在rails sql数据库中不调用表参数

e5nszbig  于 2021-06-15  发布在  Mysql
关注(0)|答案(1)|浏览(434)


我是一个新的ruby开发人员,找不到错误数据库有表,但它没有调用

<% @orders.each do |order| %>

    <tr>

        <td><%= order.listing.name %></td>
        <td><%= order.buyer.name %></td>
        <td><%= order.created_at.strftime("%B %-d, %Y") %></td>

    </tr>
    <% end %>
</table>

而且数据库在订单和清单名称中添加了一个值。
github回购总额为https://github.com/dinesh124/roughmart?files=1 此错误为nomethod error order.listing.name注册后在销售页中找不到名称

v1l68za4

v1l68za41#

订单和列表之间的关联不正确。看看你的眼睛 schema.rb -有 t.string "listing_id" 在orders表中,但它应该是整数。在迁移中更改列类型

def up
  change_column :orders, :listing_id, :integer
end

def down
  change_column :orders, :listing_id, :text
end

你需要用上下两种方法 change_column 是不可逆转的

相关问题