30 lines
791 B
Ruby
30 lines
791 B
Ruby
class ApplicationController < ActionController::Base
|
|
protect_from_forgery with: :exception
|
|
before_action :authenticate_user!
|
|
before_action :set_locale
|
|
layout :layout_by_resource
|
|
after_filter :set_headers
|
|
|
|
def set_locale
|
|
I18n.locale = params[:lang] || I18n.default_locale
|
|
end
|
|
|
|
def set_headers
|
|
headers['Access-Control-Allow-Origin'] = 'lvh.me'
|
|
headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS'
|
|
headers['Access-Control-Request-Method'] = '*'
|
|
headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
|
|
end
|
|
|
|
protected
|
|
|
|
def layout_by_resource
|
|
if devise_controller? && resource_name == :user && action_name == "new"
|
|
"devise"
|
|
else
|
|
"application"
|
|
end
|
|
end
|
|
|
|
end
|