Created
August 23, 2011 18:05
-
-
Save unakatsuo/1166020 to your computer and use it in GitHub Desktop.
Rails session localization tips.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
protected | |
def local_session | |
session[params[:controller].to_s] ||= {} | |
end | |
def reset_local_session | |
session.delete(params[:controller].to_s) | |
end | |
end | |
# This tip allows to use same session key name in different controllers. | |
# Also provides clear keys only for the controller name scope. | |
# | |
#class Page1 < ApplicationController | |
# def enter | |
# local_session[:params]=params | |
# redirect_to :action=>:confirm | |
# end | |
# | |
# def confirm | |
# if request.post? | |
# # save to file or DB | |
# reset_local_session | |
# redirect_to :action=>:finish | |
# return | |
# end | |
# end | |
# | |
# def finish | |
# end | |
#end | |
# | |
#class Page2 < ApplicationController | |
# def enter | |
# local_session[:params]=params | |
# redirect_to :action=>:confirm | |
# end | |
# | |
# def confirm | |
# if request.post? | |
# # save to file or DB | |
# reset_local_session | |
# redirect_to :action=>:finish | |
# return | |
# end | |
# end | |
# | |
# def finish | |
# end | |
#end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment