This applications follows along Component-based Rails Applications book by Stephan Hagemann.
More information: https://cbra.info/
Discusses another way to structure project files and code, following a keynote by Robert C. Martin (Uncle Bob) https://www.youtube.com/watch?v=WpkDN78P884.
I'm not totally sold on this approach, but will clarify with Stephan on his thoughts in 2020.
On updating dependencies, Stephan says
If you are following my advice to lock down dependency versions in your gemspec for external dependencies and if the gem is being used in several (or even many) of the app’s components, this process is not quite as straightforward. Within all components, we will have to update the version and in all of them we have to update the bundle.
Right now, I don't know why a dependency needs to be updated for all components.
In this section, he also gives some tips on handling Rails upgrades.
It goes into asset loading for components and tries to add ZURB to Sportsball. I'm skipping working through this section for now since it looks like it'll be another rabbit hole. A great overview of the differences in Rails 6: https://prathamesh.tech/2019/08/26/understanding-webpacker-in-rails-6/
- Stephan notes to explicitly install frontend libraries instead of relying on the ruby gem version for various reasons (Page 77-78)
At the start of Chapter 3, the book says to regenerate the project from a script. There's considerable differences between this project and what gets generated due to using Rails 5 versus Rails 6. Notably:
- Using Request specs and converting Controller specs over - Rails and RSpec team to move towards testing away implementation details in Controllers. https://rspec.info/blog/2016/07/rspec-3-5-has-been-released/#rails-support-for-rails-5
- Dropping
rails-controller-testing
as a dependency - tl;dr it's provided as a way to support existing codebases with controller tests. It's not needed since we're using request specs. rspec/rspec-rails#1393
Author makes argument for locking down dependencies with specific versions. This is done to ensure there's no drift between what's tested and what's in production.
Question: What happens if components have dependencies on the same gem, but of different versions. Does the component structure ensure there is no interference or namespace collision?.
I had no issue running bin/rails db:drop db:create db:migrate
from the main app.
When running ./build.sh
I ran into permission denied. This was because a node module has a test.sh
file and the build script was trying to run it. To bypass this I've modified the build.sh
file to ignore ./node_modules/
directory.
I had trouble getting engine route/url helpers working in request specs, where they seemed to work in controller specs. Refer to rspec/rspec-rails#2368 for more information.
After creating the prediction code and referencing the path helpers, we need to add it to components/app_component/config/routes.rb
. Otherwise I see undefined local variable or method
new_prediction_path'when loading
localhost:3000`.
I've created an errata ticket for it.
ArgumentError: Trying to register Bundler::GemfileError for status code 4 but Bundler::GemfileError is already registered
After generating game and team scaffolds, when trying to run bin/rails db:migrate
in components/app_component
, I ran into the above issue. This was an issue with rubygems, updating your rubygems to the latest should fix it.
gem update --system
Link to the Github issue on rubygems repo.