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][NY] 03/08/2012

JT Archie
Thursday, March 8, 2012

Interesting

  • Ruby MRI seems to have taken a step back in time, a dangerous, but useful feature (to some) is the goto statement.
  • It appears that DateTime object has some issues with doing math.

    DateTime.now - 1.hour #raises TypeError
    DateTime.now - 3600   #works as expected
    1.hour.class          #Fixnum
    
  • Reading the CSS property background-position in Chrome returns an invalid value. Don’t rely on it.

  • Github was hacked! They had a security issue that was a result of attr_accessible being uses incorrectly. Remember to authorize your SSH keys.
  • Need help with cron? Use http://cronwtf.github.com to convert cron into friendly English.
  • &&, ||, and ! vs. and, or, and not. It is highly recommended to always use the strict logical operators (&&, ||, and !) because the keywords
    (and, or, and not) don’t have the same operator precedence.
  • When evaluating variables in strings with bash, its better to use ${var} than $var. The curly-brace allows you to evaluate a variable with copy behind it. For example, ${var}asdf and $varasdf evaluate differently because of the expected variable name.

Help

  • Rails <3.1 has some gotchyas when using :inverse_of option.

    class Note < ActiveRecord::Base
      has_many :contacts, inverse_of: :note
    end
    
    
    class Contact < ActiveRecord::Base
      belongs_to :note, touch: true #for triggering the note observer when the contact is updated
    end
    
    
    class NotObserver
      def after_touch(note)
        note.contacts # does not have the new attributes updated unless you specify the :inverse_of
      end
    end
    
    
    # Somewhere in the code...
    contact.update_attributes....
    
  • When table names are not namespaced on a class. What is the best way to work with this if we want table names to be namespaced?

    class Foo::Bar < ActiveRecord::Base
    end
    
    
    > Foo::Bar.table_name == "bars"
    true
    
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

One comment

  1. John Pignata says:

    Actually, it seems like the 1.hour value works as expected. The 1.hour.ago value is a DateTime so that should raise a TypeError. But:

    >> DateTime.now – 1.hour
    => Fri, 09 Mar 2012 07:29:25 -0500

    This works fine and returns the expected value.

    >> 1.hour.to_i
    => 3600

    Story checks out, it’s an hour.

    >> DateTime.now – 3600
    => Wed, 01 May 2002 08:29:43 -0500

    Huh?

    March 9, 2012 at 5:34 am

Add New Comment Cancel reply

Your email address will not be published.

JT Archie

JT Archie
New York

Recent Posts

  • [NYC][Standup] 09/27/12: Protect all your attributes
  • [Standup][NYC] 09.24.2012 Moral support for the pub and sub
  • merging scopes with STI models
Subscribe to JT's Feed

Author Topics

agile (5)
  • 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 >