On 6 May 2012, at 20:22, Guillem Vidal <li...@ruby-forum.com> wrote:
> hi there!! > > I'm just trying to run a script that adds certain methods to all > ActiveRecord::Base descendants, but what happens is that it seems that > all models are loaded after the application runs > > ActiveRecord::Base.send(:descendants).each do |subclass| > #do stuff > end > > ActiveRecord::Base.send(:descendants) and > ActiveRecord::Base.send(:subclasses) is allways empty []. > > I've tried it on config/environment.rb and config/application.rb with no > success, can someone tell me what i can do about it? > You could just reopen ActiveRecord::Base. Create a new initializer (a ruby file in config/initializers) with: class ActiveRecord::Base def new_method # do stuff end end Does that help? Jeremy Walker http://www.ihid.co.uk > Thanks! > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.