- What is that 'concerns' folder that lives under models that you always delete? Why does it exist? You're about to find out!
- Mostly a code-along lightning talk
- Background: You have a scope that needs to be shared across multiple models and you don't want to repeat your code
- Example: Rails Engine -> successful_transactions scope for Merchant and Customer
- Show Rails Engine as it is prior to any refactoring ('successful_transactions' scope in both classes)
- Create the ActiveRecord::Concern for a SuccessfulTransactions module (point out that things must be wrapped in the 'included' block)
- Include the module in both models
- Add the 'it_behaves_like' statement to the spec file for each class
- Run the tests and show that it works!