Class: TermsOfUseController

Inherits:
ApplicationController show all
Defined in:
app/controllers/terms_of_use_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_navable, #current_navable=, #current_user, #point_navigation_to, #redirect_www_subdomain, #set_locale

Class Method Details

.accepted?(current_user) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/controllers/terms_of_use_controller.rb', line 23

def self.accepted?(current_user)
  current_user.accepted_terms?(current_terms_stamp)
end

.current_terms_stampObject



27
28
29
# File 'app/controllers/terms_of_use_controller.rb', line 27

def self.current_terms_stamp
  self.new.current_terms_stamp
end

Instance Method Details

#acceptObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/terms_of_use_controller.rb', line 10

def accept
  authorize! :accept, :terms_of_use
  
  if params[:accept] == 'agreed'
    flash[:notice] = I18n.t(:terms_of_use_accepted)
    current_user.accept_terms current_terms_stamp
    redirect_to (params[:redirect_after] || root_path), method: 'get'
  else
    flash[:error] = I18n.t(:you_have_to_accept_these_terms)
    redirect_to action: 'index', redirect_after: params[:redirect_after]
  end
end

#current_terms_stampObject



31
32
33
# File 'app/controllers/terms_of_use_controller.rb', line 31

def current_terms_stamp
  render_to_string('_terms', layout: false).lines.first
end

#indexObject



5
6
7
8
# File 'app/controllers/terms_of_use_controller.rb', line 5

def index
  authorize! :read, :terms_of_use
  @current_terms_stamp = current_terms_stamp
end