0
레일스를 처음 사용합니다. 특히 Rails 3과 4 사이의 변화에 대처할 때 나는 RailsCast와 MHartl의 튜토리얼을 배웠다.레일 4 레일의 StrongAttributes 캐스트 # 274
나는 성공적 RailsCast 번호 274의 코드는 아래에 링크 된 문제의 답을 사용하여 작업을 가지고 : ActiveModel::ForbiddenAttributesError in PasswordResetsController#update
내 관심이 수정, 미래의 문제 나 취약 떠날는 보안이 될 것입니다 그렇지 않으면. 이것을 할 수있는 "올바른"방법이 있다면 나는 알고 싶다. 내 코드 블록은 다음과 같습니다.
class PasswordResetsController < ApplicationController
def create
user = User.find_by_email(params[:email])
user.send_password_reset if user
redirect_to root_url, :notice => "Email sent with password reset instructions."
end
def edit
@user = User.find_by_password_reset_token!(params[:id])
end
def update
@user = User.find_by_password_reset_token!(params[:id])
if @user.password_reset_sent_at < 2.hours.ago
redirect_to new_password_reset_path, :alert => "Password reset has expired."
elsif @user.update_attributes(params.require(:user).permit(:password, :password_confirmation))
redirect_to root_url, :notice => "Password has been reset."
else
render :edit
end
end
end
엄청난 것이 내가 찾고있는 것입니다. – Puchembo