-
-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Particular usage of collapse method #111
Comments
The directory In your setup, you are collapsing |
For example, you could just configure autoloader = Rails.autoloaders.main
autoloader.collapse("app/components/button")
autoloader.collapse("app/components/form/*") If the first level ( You see. |
Hey! Closing here, please if you have any further questions about the setup do not hesitate to follow up. |
Hey sorry for the delay.
Thanks for the info, I looked on Rails engine configuration but wasn't sure since
Okay. I have a better understanding of how
I see the idea. I guess my demo app was too empty to have a good preview. I added a new component named The idea in this demo, is that the latest folder should always repeat the name of the class. So I now it's not really a conventional pattern in Rails applications. And I guess what I'm looking for is not really what |
But are those component directories, like |
The components goal is to isolate a view, a class and some assets (like css, js, images). It currently only includes one ruby file.
But I guess with some case like this one, may be annoying
Maybe it should be better to do it that way
But I also think about The pattern is I imagine 3 way to manage it:
I understand that is not a common pattern in ruby ecosystem. P.S.: Sorry if my explanations are not really clear. I've difficult to explain myself corretly on this subject 😅 |
Regarding concerns, I can't really recommend you an option, it really depends on personal preferences and how willing are you to use a custom schema at the price of configuration. The good thing about defaults is that if you follow them, all flows. The good thing about flexibility is that if the defaults do not suit you, or you want to experiment, at least you can do it with the necessary amount of configuration, and |
Just wondering, is there any way to set the autoloaders settings as part of the |
@alexpapworth Right now, in If you want to use Zeitwerk API, you need to reach for |
Awesome, good to know. I've gone with the following code, as per the current recommendations module MyApp
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.0
config.eager_load_paths << Rails.root.join("lib/components")
end
end
Rails.autoloaders.main.collapse("lib/components/concerns") |
Looks good! If you want, you can have both lines together: module MyApp
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.0
config.eager_load_paths << Rails.root.join("lib/components")
Rails.autoloaders.main.collapse("lib/components/concerns")
end
end your choice :). |
Ooh, that is definitely nicer! Thanks for feedback 😁 |
Thanks for the 2.3.0 release that add
#collapse
. (#109)I tried to used it for a similar concern but I'm not sure how to configure it for.
I did the following in an initializer:
I expect the following
But I've got this
By doing the following it works, but this mean reload server for each new component creation or renaming.
Here my demo app nicolas-brousse/avc_form_builder#1.
The text was updated successfully, but these errors were encountered: