Sha256: 4968a842520d301e30f42826943b82bbe17809c853288c8bb2c947484366e4f2

Contents?: true

Size: 1013 Bytes

Versions: 10

Compression:

Stored size: 1013 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
  end

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

  def protection_slug
    @organization&.slug
  end

  def organization_params
    params
      .require(:organization)
      .permit(:book,
              :contact_email, :name, :locale, :description,
              :logo_url, :banner_url, :open_graph_image_url, :favicon_url, :breadcrumb_image_url,
              :raise_hand_enabled, :feedback_suggestions_enabled, :public, :immersive,
              :theme_stylesheet, :extension_javascript,
              :terms_of_service, :community_link, login_methods: [])
      .tap { |it| it.merge!(book: Book.find_by!(slug: it[:book])) if it[:book] }
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mumuki-laboratory-5.6.2 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-5.6.1 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-5.6.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-5.5.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-5.4.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-5.3.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-5.2.1 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-5.2.0 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-5.1.1 app/controllers/concerns/organizations_controller_template.rb
mumuki-laboratory-5.1.0 app/controllers/concerns/organizations_controller_template.rb