Guest User

Untitled

a guest
Feb 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. class JavascriptsController < ApplicationController
  2.  
  3. def hide_announcements
  4. time = Time.now.utc
  5. set_session time
  6. set_cookies time
  7. respond_to do |format|
  8. format.html { redirect_to(root_path) }
  9. format.js { redirect_to(root_path) }
  10. end
  11. end
  12.  
  13. private
  14. def set_session(time)
  15. session[:announcement_hide_time] = time
  16. end
  17.  
  18. #TODO change expiration time to be the expiration date from the list in current_announcements
  19. def set_cookies(time)
  20. cookies[:announcement_hide_time] = {
  21. :value => time.to_datetime.to_s,
  22. :expires => time.next_week
  23. }
  24. end
  25. end
Add Comment
Please, Sign In to add comment