I was wondering why a user keeps getting signed out after editing their profile? my update function is
def update
flash[:notice] = "what is params[id]", params[:id]
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
#flash[:success] = "Profile updated"
sign_in @user
redirect_to @user
else
render 'edit'
end
end
the params id is getting passed correctly, and everything updates correctly on my db. my form in users/edit.html.erb is
<% provide(:title, "Edit user") %>
<h1>Update your profile</h1>
<div class="row">
<div class="span6 offset3">
<%= form_for @user, :html => {:multipart => true} do |f| %>
<%= render 'fields', object: f.object, f: f %>
<%= f.submit "Save changes", :class => "btn btn-large btn-primary", :style =>"display:block;" %>
<%= image_tag(@user.image_url(:thumb), :class => "image_avatar") if @user.image? %>
<%= f.file_field :image, :class=>"upload_button" %>
<% end %>
</div>
</div>
I’m using the devise gem, but this edit is not using the devise route (I’m using devise for registration). could that be affecting it?
Yes, devise has a sign_in method.
However, your users shouldn’t be signed out after editing their profile.