Skip to content

Question - What is the proper way to organize subdomain-specific components ? #168

@tdutreui

Description

@tdutreui

Hi guys :) Hope you're fine !
First, thank you for this very nice gem.

I'm currently setting up Komponent 2.2.0 in our Rails app with subdomains and I would like to completely dissociate their frontends, let's say :

domain.net
pro.domain.net

Problem : With 2 different komponent root directories, a conflict regarding the components ruby classes occurs because the modules have the same name.

Example for an "icon" component :

./frontend/components/icon/_icon.html.slim
./frontend-pro/components/icon/_icon.html.slim

Using component 'icon' on the pro subdomain views resolves the ruby class IconComponent of ./frontend instead of ./frontend-pro. The _icon.html.slim partial is correctly resolved (using prepend_view_path as stated in your doc)

I guess I should not change Rails.application.config.komponent.component_paths using before_action in a "pro" controller since its shared between subdomains, and changing global config on each request seems dangerous.

I would like to avoid namespacing my entire 'pro' component directory like ./frontend-pro/components/pro/icon/_pro_icon.html.slim since it does not look clean.

What do you advise?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions