application_controller.rb 399 Bytes
Newer Older
Eugen Rochko's avatar
Eugen Rochko committed
1 2
# frozen_string_literal: true

Eugen Rochko's avatar
Eugen Rochko committed
3 4
class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
Eugen Rochko's avatar
Eugen Rochko committed
5

6 7
  before_action :set_locale

Eugen Rochko's avatar
Eugen Rochko committed
8
  def after_sign_in_path_for(user)
Eugen Rochko's avatar
Eugen Rochko committed
9
    if user.twitter.nil?
Eugen Rochko's avatar
Eugen Rochko committed
10 11 12 13 14
      root_path
    else
      friends_path
    end
  end
15 16 17 18 19 20

  private

  def set_locale
    I18n.locale = http_accept_language.compatible_language_from(I18n.available_locales)
  end
Eugen Rochko's avatar
Eugen Rochko committed
21
end