Sha256: 0ab29c9b246c6de0760f4fa38d65f7074ded91e6191f045902783d66e4ff0ec5

Contents?: true

Size: 954 Bytes

Versions: 34

Compression:

Stored size: 954 Bytes

Contents

module OrganizationsControllerTemplate
  extend ActiveSupport::Concern

  included do
    before_action :set_organization!, only: [:show, :update, :edit]
    before_action :set_new_organization!, only: :create
  end

  private

  def set_new_organization!
    @organization = Organization.new organization_params
    @organization.validate!
  end

  def set_organization!
    @organization = Organization.locate! params[:id]
  end

  def protection_slug
    @organization&.slug
  end

  def organization_params
    params
      .require(:organization)
      .permit(:book,
              :name,
              :faqs,
              *Mumuki::Domain::Organization::Profile.attributes,
              *Mumuki::Domain::Organization::Theme.attributes,
              *(Mumuki::Domain::Organization::Settings.attributes - [:login_methods]),
              login_methods: [])
      .tap { |it| it.merge!(book: Book.find_by!(slug: it[:book])) if it[:book] }
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
mumuki-laboratory-9.23.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.22.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.21.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.20.1 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.20.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.19.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.18.1 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.18.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.17.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.16.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.15.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.14.1 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.14.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.13.2 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.13.1 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.13.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.12.1 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.12.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.11.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-9.10.0 app/controllers/concerns/organizations_controller_template.rb