Sha256: ddc6221af0e26d97f8450cf0d6d5219e80720e642f0315b02638052db9706c1c

Contents?: true

Size: 571 Bytes

Versions: 5

Compression:

Stored size: 571 Bytes

Contents

# frozen_string_literal: true

module DateBook
  # Some documentation goes here
  class DateBookController < ::ApplicationController
    helper :all
    before_action :set_locale

    # Prevent CSRF attacks using :exception in the main app
    # and :null_session in the API
    protect_from_forgery with: :exception, unless: :api_request?
    protect_from_forgery with: :null_session, if: :api_request?

    private

    def api_request?
      request.format.json?
    end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
date_book-0.0.6 app/controllers/date_book/date_book_controller.rb
date_book-0.0.5 app/controllers/date_book/date_book_controller.rb
date_book-0.0.3 app/controllers/date_book/date_book_controller.rb
date_book-0.0.2 app/controllers/date_book/date_book_controller.rb
date_book-0.0.1 app/controllers/date_book/date_book_controller.rb