Skip to content
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

Docs/fix for rails 6.0 #66

Merged
merged 5 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,18 @@ From there, you can create a `./packs` folder and structure it using the convent
If you wish to use a different directory name, eg `components` instead of `packs`, you can customize this by configuring `packs.yml`. See [`packs`](https://github.com/rubyatscale/packs) for more information.

### Splitting routes
`packs-rails` allows you to split your application routes for every pack. You just have to create a file describing your routes and then `draw` them in your root `config/routes.rb` file.
`packs-rails` allows you to split your application routes for every pack. You just have to create a file describing your routes and then `draw` them in your root `config/routes.rb` file (NOTE: the `draw` function is only in Rails 6.1+).

```ruby
# packs/my_domain/config/routes/my_domain.rb
resources :my_resource
Rails.application.routes.draw do
resources :my_resource
end

# config/routes.rb
draw(:my_domain)
Rails.application.routes.draw do
draw(:my_domain)
end
```

### Making your Package an Engine
Expand Down
4 changes: 4 additions & 0 deletions lib/packs/rails/integrations/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def create_engines
def inject_paths
Packs.all.reject(&:is_gem?).each do |pack|
Packs::Rails.config.paths.each do |path|
# Example case: in rails 6.0, the "config/routes" app path is nil and was not added until
# https://github.com/rails/rails/pull/37892/files#diff-a785e41df3f87063a8fcffcac726856a25d8eae6d1f9bca2b36989fe88613f8eR62
next unless @app.paths[path]

@app.paths[path] << pack.relative_path.join(path)
end
end
Expand Down