Created
January 5, 2009 12:28
-
-
Save drogus/43374 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
private | |
def set_cookie(name, value) | |
@search_options ||= {} | |
cookie_value = cookie[name] | |
if value != cookie_value | |
# jeżeli ciasteczko do tej pory miało inną wartość | |
# to zmień wartość ciasteczka i zapisz to do hasha z opcjami | |
cookies[name] = @search_options[name] = value | |
else | |
# jeżeli nie było zmiany kasujemy daną wartość z hasha | |
@search_options.delete(name) | |
end | |
end | |
def get_cookie(name) | |
@search_options ||= {} | |
# zwraca daną opcję albo ciasteczko jeżeli opcja się nie zmieniło | |
@search_options[name] || cookies[name] | |
end | |
helper_method :get_cookie |
This file contains hidden or 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
# w controllerze | |
set_cookie(:calendar, "#{params[:costam]}-#{params[:cos_innego}) | |
# w widoku | |
get_cookie(:calendar) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment