0

这是我的看法:

  <%= link_to_remote "Responded - Positive",
      :url => contact_path(@contact, :status => 'positive response'),
      :update => "status" %>

这就是我的路线:

  map.resources :contacts, :has_one => :status_contact

这是我在控制器中使用的:

  def create
    @status_contact = StatusContact.new(params[:status_contact])
    if @status_contact.save
      #flash[:notice] = "Successfully created status contact."
      #redirect_to @status_contact
      render :text => "Set status to #{@status_contact.status}."
    else
      render :text => "bomb"
    end
  end

我想要的结果是,对于特定的联系人,它将使用值“积极响应”更新属性 Contact.status 并通过 ajax 执行此操作。

现在,我收到 404 错误。我需要做什么来纠正这个问题?

这是我仍然得到的错误:

POST http://localhost:3000/contacts/24?method=put&status=positive+response 404 Not Found
    312ms
4

1 回答 1

0

您可能使用错误的动词发送请求(:post 而不是 :put)。您试图达到控制器的哪个操作?这可能是更新操作...尝试通过指定 :put 方法来修改您的链接:

<%= link_to_remote "Responded - Positive", :url => contact_path(@contact, :status => 'positive response'), :method => :put, :update => "status" %>
于 2010-10-05T06:31:30.113 回答