0
我希望能夠爲改變值:status_contact爲模型聯繫(HAS_ONE:status_contact如何通過link_to_remote更新a:has_one值?
這裏是與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控制檯通過網址:
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>
嗨,所以如果我使用contact_path而不是contacts_url,我很好走? – Angela 2010-09-25 04:54:13
是的。請記住,首先使用純HTML進行操作,然後添加JavaScript。這有兩個原因:1)不顯眼,2)按此順序執行更容易。 – s84 2010-09-25 17:59:46
仍然收到一個錯誤,見上面.... – Angela 2010-09-26 16:11:32