Skip to content

Commit 8d32418

Browse files
committed
docs: note about lib/ autoload
Ref #39
1 parent 28f3994 commit 8d32418

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ bundle exec rails g view_component -h
4747
**Why adding a custom generator to the project instead of bundling it into the gem?** The generator could only be useful if it fits
4848
your project needs. The more control you have over the generator the better. Thus, the best way is to make the generator a part of a project.
4949

50+
> [!IMPORTANT]
51+
> If your application has the `lib/` folder in the autoload paths, make sure you ignored the generated `lib/generators` folder. In Rails 7.1+, you can do this via adding `generators` the `config.autoload_lib` call's `ignore` option. Before, you can use `Rails.autoloaders.main.ignore(...)`.
52+
5053
## Organizing components, or sidecar pattern extended
5154

5255
ViewComponent provides different ways to organize your components: putting everyhing (Ruby files, templates, etc.) into `app/components` folder or using a _sidecar_ directory for everything but the `.rb` file itself. The first approach could easily result in a directory bloat; the second is better though there is a room for improvement: we can move `.rb` files into sidecar folders as well. Then, we can get rid of the _noisy_ `_component` suffixes. Finally, we can also put previews there (since storing them within the test folder is a little bit confusing):

0 commit comments

Comments
 (0)