Sha256: af20161e5aacf460d5a064515e533c64e53a5c4cecf9c14c2e70ab579b159919

Contents?: true

Size: 916 Bytes

Versions: 2

Compression:

Stored size: 916 Bytes

Contents

module MegaBar
  class ApplicationController < ActionController::Base
    # Prevent CSRF attacks by raising an exception.
    # For APIs, you may want to use :null_session instead.
    protect_from_forgery with: :exception
    helper_method :sort_column, :sort_direction, :is_displayable, :might_paginate?, :might_filter?
    before_action :set_vars_for_all
    before_action :set_vars_for_displays # , except: [:update, :create, :destroy]
    skip_before_filter :verify_authenticity_token

    def _params
      permits = []
      MegaBar::Field.by_model(env[:mega_env][:modle_id]).order('data_type desc').each do |att|
        case att.data_type
        when 'array'
          permits << { att.field => [] }
        else
          permits << att.field unless ['id', 'created_at', 'updated_at'].include?(att)
        end
      end
      params.require(controller_name.singularize).permit(permits)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mega_bar-0.5.2 app/controllers/mega_bar/application_controller.rb
mega_bar-0.5.1 app/controllers/mega_bar/application_controller.rb