I am using Restful_Authentication plugin for login/logout. I am trying to update the profile page which has columns email and fname etc, its updating only the email column but not updating the fname and other columns once i hit save and gives me flash message as 'Profile was successfully updated. Please let me know how can i fix it to update all fields not just email field.
-- following is the code in my users_controller.rb :-
class UsersController < ApplicationController # render new.rhtml def new @title = 'new' end
def create cookies.delete :auth_token # protects against session fixation attacks, wreaks havoc with # request forgery protection. # uncomment at your own risk # reset_session @user = User.new(params[:user]) @user.save if @user.errors.empty? self.current_user = @user redirect_back_or_default('/session/new') flash[:notice] = "Thanks for signing up!" else render :action => 'new' end end
def update @user = User.find(params[:id])
respond_to do |format| if @user.update_attributes(params[:user]) flash[:notice] = 'Profile was successfully updated.' format.html { redirect_to :controller => 'sessions', :action => 'edit_profile' } format.xml { head :ok } else flash[:error] = 'Unable to update profile.' format.html { render :controller => 'sessions', :action => 'edit_profile' } format.xml { render :xml => @user.errors, :status => :unprocessable_entity } end end end
def edit @user = User.find(params[:id]) end
end
-- following is the code in my edit_profile.html.erb file located in (views/sessions/edit_profile):-
<h2> Edit Profile </h2> <% form_for @current_user do |f| %> <%= f.error_messages %>
<p> <%= f.label :email %><br /> <%= f.text_field :email %> </p> <p> <%= f.label :fname %><br /> <%= f.text_field :fname %> </p> <p> <%= f.label :middle_name %><br /> <%= f.text_field :mname %> </p> <p> <%= f.label :last_name %><br /> <%= f.text_field :lname %> </p> <p> <%= f.submit "Save" %> </p> <% end %>
Attachments: http://www.ruby-forum.com/attachment/2914/users_controller.rb