로그인 한 사용자가 편집 페이지에서 프로필 정보를 변경하고 비밀번호를 입력하지 않아도되게하려면 어떻게하면 효과적으로 변경할 수 있습니까? 이 UsersController?before_filter를 프로필 편집을 위해 비밀번호가 필요하지 않도록 변경하십시오.
UsersController :
before_filter :authenticate, :except => [:show, :new, :create]
before_filter :authenticate, :only => [:index, :edit, :update, :destroy]
before_filter :correct_user, :only => [:edit, :update]
before_filter :admin_user, :only => :destroy
def edit
@title = "Edit user"
end
def update
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
flash[:success] = "Profile updated."
redirect_to @user
else
@title = "Edit user"
render 'edit'
end
end
페이지 편집
</div>
<h1> Confirm Password</h1><br /><br />
<div class="field">
<%= f.label :password, "Enter Password" %>
<%= f.password_field :password %>
</div>
<div class="field">
<%= f.label :password_confirmation, "Confirm Password" %>
<%= f.password_field :password_confirmation %>
</div>
<div class="actions">
<%= f.submit "Submit" %>
</div>
<% end %>
</div>
흠, 내가 아는 것은 아닙니다. 그냥, 내 편집 (업데이트) 페이지에서 이미지 업로드시 비밀번호를 확인하는 양식이 있으며 비밀번호가 올바르게 입력되지 않으면 작동하지 않습니다. – Elias7
아주 이상하게, 나는 너를 인증으로 다시 쓰겠다. 인증을하는 것은 비실용적입니다. [Rails Tutorial Sessions] (http://ruby.railstutorial.org/chapters/sign-in-sign-out#top)을 살펴보고이를 모범 사례로 사용하십시오. – icantbecool