我有一個單一形式的用戶屬性約60個字段,通過在一個頁面上切換隱藏div單獨顯示。更新其他人的個人資料時,所有字段均按預期進行更新。更新當前登錄的配置文件(current_user)時,只有大約40個字段會更新。這是我正在觀察current_user配置文件的更新方法:紅寶石Rails只有一些參數傳遞給控制器
當在@user = User.find(params [:id])之後直接設置斷點並查看傳入的參數時,只有大約40個out 60表單字段參數甚至存在。那些目前正在更新的,並且顯然不存在的不會更新。
任何線索可能會導致這種奇怪的行爲?
示例:用戶/ _form.erb許多誤運行得表單字段
<%= f.text_field :street_address, :placeholder => 'address..' %>
更新方法在users_controller.rb
# UPDATE
def update
@user = User.find(params[:id])
breakpoint_set = on_this_line
respond_to do |format|
if @user.update_attributes params[:user]
format.html do
redirect_to("/users", :notice => 'User Profile was successfully updated.')
format.xml { head :ok }
end
else
format.html { render :action => "edit" }
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
end
end
end
是您的示例代碼中的類型? <%= @ .text_field ...? –
這是一個錯字,我將它改爲f。但不幸的是,這不是問題。 – iamtoc
我試圖無效的其他事情是在所有字段上使用attr_accessible並重新啓動服務器。我有點想法。 – iamtoc