rails,用户在编辑个人资料后退出? [英] rails, user signing out after editing profile?
本文介绍了rails,用户在编辑个人资料后退出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道为什么用户在编辑个人资料后仍然不断注销?我的更新函数是
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
params id
得到正确的传递,并且所有内容都在我的数据库上正确更新。我在 users / edit.html.erb
中的表单是
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>
我正在使用 devise gem
,但是此修改未使用设计路线(我正在使用设计进行注册)。
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?
推荐答案
是的,devise有一个登录方法。
Yes, devise has a sign_in method.
但是,您的用户应该将不会在编辑他们的个人资料后退出。
However, your users shouldn't be signed out after editing their profile.
这篇关于rails,用户在编辑个人资料后退出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文