Ruby Video
Talks
Speakers
Events
Topics
Leaderboard
Sign in
Talks
Speakers
Events
Topics
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
By, Claudio Baccigalupo In Rails 5, the old way of returning false to implicitly halt a callback chain will not work anymore. This change will impact any codebase using ActiveSupport, ActiveRecord, ActiveModel or ActiveJob. Methods like before_action, before_save, before_validation will require developers to explicitly throw an exception in order the halt the chain. This talk will explain the motivations behind the new default, will delve into the internals of Rails to show the actual code, and will help developers and gem maintainers safely upgrade their apps to Rails 5.
Date
Summary
Markdown supported
### Introduction In this presentation at RailsConf 2015, Claudio Baccigalupo discusses the changes introduced in Rails 5 regarding callback chains and the necessary adjustments developers need to make to their codebases. The traditional method of returning false to halt callbacks is deprecated, necessitating a clearer and more explicit way to manage these control flows. ### Key Points - **Deprecated Behavior**: The reliance on returning false to stop a callback chain is no longer valid in Rails 5. This modification specifically affects codebases utilizing ActiveSupport, ActiveRecord, ActiveModel, or ActiveJob. - **New Methodology**: Developers are now required to explicitly raise exceptions in order to appropriately halt callback chains. This leads to improved clarity in code, making behaviors more predictable and readable. - **Backward Compatibility**: Rails 5 attempts to maintain some level of backward compatibility. While existing code will still function, it will trigger warnings about deprecated practices, encouraging developers to update their code for greater reliability. - **Code Review and Adaptation**: Developers are advised to conduct audits of their existing applications. Identifying and revising the use of callbacks will be crucial in aligning with the new Rails 5 standards. - **Opportunities for Improvement**: The transition to using exceptions instead of implicit false returns is presented as an opportunity to refine coding standards. Clearer practices will lead to reduced bugs and enhance maintainability in applications. - **Emphasis on Learning**: Baccigalupo encourages the community to adapt to these new standards proactively and to share experiences for collective growth. The shift toward explicitness in callbacks is positioned as an evolution of the Rails framework. ### Conclusion The changes in Rails 5 necessitate a shift in how developers handle callbacks, moving from implicit behaviors to explicit control via exceptions. While this transition may involve some initial learning curve, it promises more robust and maintainable code in the long run. As the community adapts to these changes, open discussions and collaboration will be vital for navigating this evolution in Rails practices.
Suggest modifications
Cancel