I have a single form of user attributes with about 60 fields, displayed separately by means of toggling hidden divs all on one page. When updating someone else’ profile, all fields update as expected. When updating the current logged in profile (current_user), only about 40 of the fields update. Here’s what I am observing on the update method for the current_user profile:
When setting a breakpoint directly after @user = User.find(params[:id]) and looking at the parameters that got passed, only about 40 out of the 60 form field parameters are even present. The ones that are present update as expected, and obviously the ones that aren’t present don’t update.
Any clues as to what might be causing this strange behavior?
Example: one of many mis-behaving form fields on users/_form.erb
<%= f.text_field :street_address, :placeholder => 'address..' %>
Update Method in 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
Check if the parameters are porting to the controller from client side. You may check this will Firefox + Firebug console.
And check if every parameter is under the user hash, because the missing parameters might not coming in the same user hash (which the Rails controller is looking at).