0

モデル Contact の :status_contact の値を変更できるようにしたい (has_one :status_contact

link_to_remote を含むスニペットは次のとおりです。

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

Contact.rb の関連するモデル定義は次のとおりです。

  has_one :status_contact
  alias_attribute :status, :status_contact

エラーから、おそらく特別なルートを作成する必要があるようです?

http://localhost:3000/contacts/22
404 Not Found

link_to_remote をクリックすると、ajax を介して値が変更されるようにするにはどうすればよいですか?

更新: 以下の変更を行った新しいエラー:

:url=> contact_path(@contact, :status => 'positive response')

コントローラーで探しているアクションがわかりません。「更新」アクションがあります。これは、Firebug コンソールを介して渡される URL です。

http://localhost:3000/contacts/16?status=positive+response

<h1>Unknown action</h1>
<p>No action responded to 16. Actions: build_date_from_params, create, destroy, edit, index, message_sub, new, set_contact_delay, set_contact_email, set_contact_phone, set_contact_title, show, and update</p>
4

1 に答える 1

0

contacts_urlにマップします:controller => "some_controller", :action => "index"

必要なのは、アクションを次のように変更することですupdate

これの正しいルートはcontact_path

于 2010-09-25T03:32:38.063 に答える