Sha256: 89ddcc013e977177452e5b8598f3cd0d250e8fa810cda95fc5799bfea0d3e621

Contents?: true

Size: 942 Bytes

Versions: 14

Compression:

Stored size: 942 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,
              *Mumukit::Platform::Organization::Profile.attributes,
              *Mumukit::Platform::Organization::Theme.attributes,
              *(Mumukit::Platform::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

14 entries across 14 versions & 1 rubygems

Version Path
mumuki-laboratory-6.7.7 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-6.7.6 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-6.7.5 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-6.7.4 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-6.7.3 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-6.7.2 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-6.7.1 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-6.7.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-6.6.1 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-6.6.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-6.5.1 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-6.5.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-6.4.2 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-6.4.1 app/controllers/concerns/organizations_controller_template.rb