Witam
Przerobiłem niedawno polecany na tym forum tutorial do Authlogic:
http://railscasts.com/episodes/160-authlogic
Mam 2 pytania.
- Czy poniższych kod zadziała na serwerze jeśli będzie się logować mnóstwo osób. Jak jest z wytrzymałością?
[code=ruby]# Filters added to this controller apply to all controllers in the application.
Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
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
end[/code]
[code=ruby]class UserSessionsController < ApplicationController
def new
@user_session = UserSession.new
end
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
end[/code]
2. Jak zrobić odwołanie do ostatniej odwiedzonej strony? Jest jakaś zmienna predefiniowana?
Z góry dziękuje za odpowiedź.