Sha256: 92cbf4e816691a7164283831b4c02eb23abb95dbca73ba47fdd3ba4ba095a055

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

class ApplicationController < ActionController::Base
  add_flash_types :error, :success, :notice
  # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
  allow_browser versions: :modern

  protected

  # Adjust the value of <resource_owner_id> in db/structures/<resource>_structure.yaml
  # Ignore this comment if you haven't generated the structure yet

  #def <resource_owner_id>
  #   current_auth.<resource_owner_id>
  #end

  def build_form_errors(params, model, errors)
    params.keys.each do |key|
      model[key] = params[key]
    end
    if errors.is_a?(Hash)
      errors.keys.each do |key|
        model.errors.add(key, :invalid, message: errors[key][0])
      end
    elsif errors.is_a?(Array)
      errors.each do |error|
        if error.options.present?
          model.errors.add(error.attribute, error.type, message: error.options['message'])
        else
          model.errors.add(error.attribute, error.type)
        end
      end
    end
    model
  end

  def set_layouts
    # "#{current_auth.user.role}/application"
    'owner/application'
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sun-sword-0.0.9 lib/generators/sun_sword/templates_frontend/controllers/application_controller.rb.tt
sun-sword-0.0.8 lib/generators/sun_sword/templates_frontend/controllers/application_controller.rb.tt
sun-sword-0.0.7 lib/generators/sun_sword/templates_frontend/controllers/application_controller.rb.tt
sun-sword-0.0.6 lib/generators/sun_sword/templates_frontend/controllers/application_controller.rb.tt