Sha256: 278f758db0265a78eeab645e612dd77226fc63077cae7761713974e8c52b4a44
Contents?: true
Size: 841 Bytes
Versions: 8
Compression:
Stored size: 841 Bytes
Contents
module ActiveRecordSurveyApi class ApplicationController < ActionController::Base before_filter :set_locale def serialize_model(model, options = {}) options[:is_collection] = false ((options[:serializer]) ? options[:serializer] : JSONAPI::Serializer).serialize(model, options) end def serialize_models(models, options = {}) options[:is_collection] = true ((options[:serializer]) ? options[:serializer] : JSONAPI::Serializer).serialize(models, options) end private def set_locale # If a language is sent - it's the preferred language! if !request.headers[:HTTP_ACCEPT_LANGUAGE].to_s.empty? http_accept_language.user_preferred_languages = [request.headers[:HTTP_ACCEPT_LANGUAGE].to_s] end I18n.locale = http_accept_language.compatible_language_from(I18n.available_locales) end end end
Version data entries
8 entries across 8 versions & 1 rubygems