Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

Standup for 2/9/2012: NP in P time? As usual, no.

Ask for Help

“How can I know all the descendants of a class in the superclass at load time in ruby? I want to create a scope for each subclass.”

You can’t.

“What popovers should I use?”

We’ve used at least these two before:

“What recurring billing system should I use?”

We’ve had good luck with BrainTree and Recurly.

Interesting Things

  • backbone-forms is a plugin to backbone that provides model-based form views similar to rails’ form_for functionality.
  • EmberJS meetup will be Feb 21, at our new pivotal office!

  1. nakajima says:

    You *could* use the `inherited` hook:

    class Superklass
    def self.inherited(subclass)
    puts “lol, #{subclass} just inherited from me”

    class Subclass1 < Superklass end class Subclass2 < Superklass end prints this: lol, Subclass1 just inherited from me lol, Subclass2 just inherited from me You probably shouldn’t tho.

  2. Avdi says:

    As the previous commenter points out, you very much can, unless we’re misunderstanding the question.

  3. David Stevenson says:

    We want to define named scopes in the superclass at load time, one for each subclass. Something like this won’t work:

    class A < ActiveRecord::Base subclasses.each do |subclass| named_scope "for_#{subclass}", where(:type => subclass)

    Because the subclasses haven’t all been defined at the time of load. The `self.inherited` callback will probably work to dynamically define named scopes for each subclass. The problem used to be ensuring that all the subclasses are loaded before the scopes are invoked, but we can solve that with eager loading of classes in rails. Thanks!

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *