【发布时间】:2017-05-16 03:22:27
【问题描述】:
我在订单中添加了争议新链接,但 Rails 日志显示
既然争议与模型中的顺序有关,为什么还要显示未定义的局部变量或方法?
未定义的局部变量或方法 `new_dispute' for
有人知道为什么吗?
view/_order.html.erb <ul> <li>Order: <b><%= order.transaction.transaction_id %></b></li> <li>seller:<%= order.seller_name %></li> <li><%=link_to"Create New Dispute", new_dispute %></li> </ul> disputer controller class DisputesController < ApplicationController def new @order = current_user.cart.orders.find(params[:id]) if current_user.address.blank? redirect_to edit_user_path flash[:error] = 'error' else @dispute = Dispute.new end end end class Order < ActiveRecord::Base has_one :dispute end class Dispute < ActiveRecord::Base # attr_accessible :title, :body belongs_to :order ' end
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-4