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

おそらく、間違った動詞 (:put ではなく :post) を使用してリクエストを送信している可能性があります。コントローラーのどのアクションに到達しようとしていますか? それはおそらく更新アクションです... :put メソッドを指定してリンクを変更してみてください:

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