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 10/30/08

Rajan Agaskar
Thursday, October 30, 2008

Interesting Things

  • Removing class definitions with Object.send(:remove_const, :Foo)

Sometimes it is necessary to reload or replace a stub/test class during testing (apparently rspec is particularly susceptible to this). This can be achieved using Object.send(:remove_const, :Foo) where Foo is the camel-cased name of the class. If your class is defined within a module, it may be necessary to use Module.send(:remove_const, :Foo)

Ask for help

  • foo.bar.reload versus foo.bar(true)

As a point of curiosity, does anybody know when has_many relationship reloading moved from (or to?) foo.bar(true) to foo.bar.reload? The reload syntax seems preferable for readability; will foo.bar(true) continue to work in the future?

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

One comment

  1. Pat Nakajima says:

    Calling `#reload` is just an instance method on ActiveRecord::Base to reload whatever object you call it on from the database. Since the `bar` in `foo.bar` is just an ActiveRecord, you can reload it.

    The `foo.bar(true)` syntax is an association proxy specific way of reloading your association.

    I think.

    October 31, 2008 at 2:01 pm

Add New Comment Cancel reply

Your email address will not be published.

Rajan Agaskar

Rajan Agaskar
San Francisco

Recent Posts

  • Restart post-migration
  • Capybara 2.0 is out.
  • Try using Mongo
Subscribe to Rajan's Feed

Author Topics

  • 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 >