How can / should I override the `build` method for a my model?
class, methods, overriding, ruby, ruby-on-rails
Solution
There is a way to customize your build method , define your `build` in model relations:
class Article
has_many :comments do
def build(*args, &block)
#TODO your code
super(*args, &block)
end
end
end
If you don't need default params of build method, then you can use your own.
Problem
I am using Ruby on Rails 3.2.13 and, since in my previous question "How should I use the alias_method_chain for the build method?" it seems that any solution has been found, I am considering to override the `build` method in a my model class in order to get the wanted behavior. How can / should I override the `build` method for a my model (even when the `build` method runs for `ActiveRecord` associations as-like `@article.comments.build(...)`)?