這是我有我的觀點:如何使用link_to_remote更新Rails AR中的關聯(has_one)?
<%= 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
今天要問很多問題,我們不是嗎? ;] – karlphillip 2010-10-05 04:51:40
太多不知道:( – Angela 2010-10-05 16:13:04