Class: RailsImagePostSolution::ApplicationController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/rails_image_post_solution/application_controller.rb

Instance Method Summary collapse

Instance Method Details

#default_url_optionsObject

Ensure default_url_options includes locale



35
36
37
38
39
40
41
# File 'app/controllers/rails_image_post_solution/application_controller.rb', line 35

def default_url_options
  if defined?(super)
    super.merge(locale: I18n.locale)
  else
    { locale: I18n.locale }
  end
end

#require_adminObject

Add require_admin method for admin controllers



23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/rails_image_post_solution/application_controller.rb', line 23

def require_admin
  unless logged_in?
    redirect_to , alert: I18n.t("errors.messages.login_required")
    return
  end

  unless current_user.admin?
    redirect_to root_path, alert: I18n.t("errors.messages.admin_required")
  end
end

#require_loginObject

Override require_login to use main_app routes



16
17
18
19
20
# File 'app/controllers/rails_image_post_solution/application_controller.rb', line 16

def 
  unless logged_in?
    redirect_to , alert: I18n.t("errors.messages.login_required")
  end
end