我有一个模型用户,它有一个 user_profile 和一个 User_Profile belongs_to 用户
在用户控制器中,我有:
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%>
在我的轮回中:
map.resources :users, :member => {
:personal => :get,
:update_personal => :put
}
现在奇怪的是我可以做到:
users/1/personal
查看表单,但是当我提交时出现此错误:
Unknown action
No action responded to 1.
它试图找到一个名为 1 的动作。
谁能指出我正确的方向?