Is there any design pattern in Rails by which i can use helper methods in models, without using include ActionView::Helpers
?
ActionView::Helpers are intended to be used in your view code. If you have code that you want to use in you model and view, I would recommend creating a helper method in your model.
If you want to create a method that is used in multiple models, I would use concerns. Concerns are used to extract common chunks of code from models to DRY them up. Look here for more info
An alternative to concerns is to create a superclass for common models to inherit from where you can add helper methods
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments