인증을 위해 authlogic gem을 사용하고 있습니다. 나는 다음과 같은 코드를 한 http://railscasts.com/episodes/160-authlogic레일의 authlogic
: 나는의 단계를 따라했습니다
# config/environment.rb
config.gem "authlogic"
# models/user.rb
acts_as_authentic
# users_controller.rb
def create
@user = User.new(params[:user])
if @user.save
flash[:notice] = "Registration successful."
redirect_to root_url
else
render :action => 'new'
end
end
def edit
@user = current_user
end
def update
@user = current_user
if @user.update_attributes(params[:user])
flash[:notice] = "Successfully updated profile."
redirect_to root_url
else
render :action => 'edit'
end
end
# user_sessions_controller.rb
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
flash[:notice] = "Successfully logged in."
redirect_to root_url
else
render :action => 'new'
end
end
def destroy
@user_session = UserSession.find
@user_session.destroy
flash[:notice] = "Successfully logged out."
redirect_to root_url
end
# application_controller.rb
filter_parameter_logging :password
helper_method :current_user
private
def current_user_session
return @current_user_session if defined?(@current_user_session)
@current_user_session = UserSession.find
end
def current_user
return @current_user if defined?(@current_user)
@current_user = current_user_session && current_user_session.record
end
# config/routes.rb
map.login "login", :controller => "user_sessions", :action => "new"
map.logout "logout", :controller => "user_sessions", :action => "destroy"
내가 모든 작업 있어요 나는 내가 게시하는 사용자 추적 할 수 있습니다 세션에서 USER_ID을하고 싶은 제외하는 게시물을 어디에 설정해야합니까?
는
내가 그런 식으로 찾아 주셔서 감사합니다. – Adnan