【问题标题】:Rails why undefined local variable or method `new_dispute' for #<#<Class:0x007fec13d18678>Rails 为什么为#<#<Class:0x007fec13d18678> 定义未定义的局部变量或方法`new_dispute'
【发布时间】: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


    【解决方案1】:

    试试new_dispute_path

    并在此处阅读有关这些内容的所有信息 :)

    http://guides.rubyonrails.org/routing.html#path-and-url-helpers

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-16
      • 1970-01-01
      相关资源
      最近更新 更多