Skip to content

Commit

Permalink
Also set default url and set locale per request for Administrate
Browse files Browse the repository at this point in the history
  • Loading branch information
lauramosher authored and mirandawang committed Oct 4, 2018
1 parent 21f2e91 commit da5342a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions rails/app/controllers/admin/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ class ApplicationController < Administrate::ApplicationController
before_action :authenticate_user!
before_action :authenticate_admin

before_action :set_locale

def default_url_options
{ locale: I18n.locale }
end

private

def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end

def authenticate_admin
redirect_to '/', alert: 'Not authorized.' unless current_user && current_user.editor?
end
Expand Down

0 comments on commit da5342a

Please sign in to comment.