Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

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

David Stevenson
Thursday, February 9, 2012

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:

  • QTip
  • Tipsy

“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!
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

3 Comments

  1. nakajima says:

    You *could* use the `inherited` hook:

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

    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.

    February 9, 2012 at 3:34 pm

  2. Avdi says:

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

    February 9, 2012 at 7:40 pm

  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)
    end
    end

    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!

    February 9, 2012 at 10:10 pm

Add New Comment Cancel reply

Your email address will not be published.

David Stevenson

David Stevenson
San Francisco

Recent Posts

  • 03/13/13: [SF] Use postgres!
  • Standup 2/6/2012: Tracker UI updates
  • Standup for 5/13/2011: requiring yaml and psyche, order matters
Subscribe to David's Feed

Author Topics

agile (10)
devise (1)
ec2 (1)
engines (1)
ios (1)
activerecord (3)
inverse_of (1)
css (2)
engineyard (1)
iphone (3)
rubymine (1)
rails (5)
aws (1)
javascript (1)
xmpp (1)
gogaruco (3)
activeresource (1)
heroku (1)
solr (1)
bug (1)
patch (1)
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >