railscasts.comのおかげでカスタム認証がいくつか作成されましたが、ユーザーのプロフィールを編集しないように制限する必要があります。カスタム認証のヘルプが必要
はここに私のauthenticate_userとCURRENT_USER方法です:
private
def current_user
@current_user ||= User.find_by_auth_token!(cookies[:auth_token]) if cookies[:auth_token]
end
def authenticate_user!
if current_user.nil?
redirect_to login_url, :alert => "You must first log in to access this page"
end
end
ここに私のがUserControllerでbefore_filterです:
before_filter :authenticate_user!, :only => [:edit, :update, :destroy]`
EDIT:は感謝をalock27するためにそれを修正しました。
私は私のusers_controllerを編集し、次のように編集アクションを変更する必要がありました:
@user = User.find(params[:id]
redirect_to root_url unless current_user == @user
あなたはDeviseを使用していますか? – efoo
いいえ、それはrailscasts.comのチュートリアルを使用して構築されたカスタム認証システムです:p – imjp