RubyonRails

Profile Updation in Rails

Account Controller –>

session[:user_id]= self.current_user.id

HOME Controller inside:

def list
end

def search
@user = User.find(session[:user_id])
if @user.update_attributes (params[:user])
flash[:notice] = ‘User Name was successfully updated.’
redirect_to :action => ‘index’, :id => @user
else
redirect_to :action => ‘list’
end

end

LIST.RHTML

<%= start_form_tag :action => ‘search’ %>
<%= text_field ‘user’,’name’ %>
<%= text_field ‘user’,’age’ %>
<%= submit_tag ‘Update Profile’ %>

<% end_form_tag %>

INDEX.RHTML

<%= flash[:notice] %>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s