0
我有HAS_ONE user_profile模型的用戶,並在用戶控制器User_Profile belongs_to的用戶路由使用ID已經動作和動作已經提交表單
後ID我:
def personal
@user = User.find_by_id(params[:id])
@user_profile = @user.user_profile
@user_profile ||= @user.build_user_profile
end
def update_personal
@user = User.find_by_id(params[:id])
if @user.user_profile.update_attributes(params[:user_profile])
flash[:notice] = "OK"
redirect_to @user
else
flash[:notice] = "Fail"
render :action => 'update_personal'
end
end
在我personal.html.erb觀點我有:
<% semantic_form_for @user_profile, :url => { :action => "update_personal"} do |form| %>
<%= form.inputs %>
<%= form.buttons %>
<%end%>
而且在rountes我:
map.resources :users, :member => {
:personal => :get,
:update_personal => :put
}
現在奇怪的是,我可以這樣做:
users/1/personal
看到的形式,但是當我提出我得到這個錯誤:
Unknown action
No action responded to 1.
它試圖找到與該名字的動作1.
任何人都可以指出我正確的方向嗎?
經過很多小時試圖找出這一個......這很簡單。 只需重新啓動服務器。 X_X – 2010-05-14 18:42:39