Topic: Not able to update user account table

I am getting username, password and displayname during account signup and i am putting these values in user table. I have one more table 'userprofile' which is used for storing firstname, lastname and other personal details.

I want to update these personal details and displayname(which is in user table)from ONE particular page. I can able to update personal details but not 'displayname'

  my controller for updating the form values is given below:

      usPrid = params[:userprofile][:id]
      dname = params[:displayname]
     usPr = Userprofile.find(usPrid)
     userdn = User.find(usPr.user_id)
     userdn.displayname = dname

  Can you please tell me why that 'displayname' is not getting updated? am i missing some thing? or Is there any restrictions in updating user account table?


Thanks in advance.


Re: Not able to update user account table

There are no restrictions in updating any table - unless you had a column called 'type' - but you don't.

Have you checked to see that the right info is in the params?  You could do it like this (I've rewritten your code a little):

  @profile = Userprofile.find(params[:userprofile][:id])
  @user = @profile.user
  if params[:displayname].empty?
    flash[:error] = "There was no displayname specified"
    @user.displayname = params[:displayname]