ruby on rails - How can you override the activerecord has_many assoication build method? -


i override build method of has_many assoication.

class otherthings < activerecord::base   belongs_to :my_model end  class mymodel < activerecord::base   has_many :other_things end 

such that

m = mymodel.create m.other_things.build  # i'd add additional logic within build method... 

i have gone updating new method of otherthings, getting little messy. i'd logic happen when being associated hence build...

im unsure of trying build. if trying add more methods attach .whatever_method end. also, models associated.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -