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