John Pignata's blog



John PignataJohn Pignata
NYC Standup Roundup - Week of 12/7
edit Posted by John Pignata on Friday December 11, 2009 at 02:34PM

Interesting

   >> false.blank?
   => true
  • blank? first checks to see if a method responds to empty? and if not evaluates !self which in false's case will always be true. This caused a pair a bit of confusion when trying to validate the completeness of a form that had a checkbox.

  • Railscamp — an all-weekend hackfest — is being held in Rhode Island in March of next year.

  • All API keys were recently reset on Gemcutter due to a security bugfix - in order to publish gems you'll need to update your gemcutter gem to regenerate your key.

  • Postgres will return an error if you attempt to ORDER BY columns that are not specified in the SELECT. This is painful in cases where you're using DISTINCT with any kind of JOIN.

  • One team cut their deployment down from 7 minutes to 30 seconds with a few cap recipe tweaks. Most of the time was saved by symlinking gem bundler-related directories to prevent bundler from building native gems on each deploy and by only running database migrations when anything in db/migrate had changed.

  • When using the inherited hook for ActiveRecord::Base, beware of tables that have their name overriden by set_table_name. The inherited hook will execute prior to that statement being evaluated which can cause strange results.

  • Getting Selenium to work with Snow Leopard involves some manual file renaming hackery — for anybody struggling with this there are a couple of posts out there to walk you through the process.

John PignataJohn Pignata
NYC Standup Roundup - Week of 11/30
edit Posted by John Pignata on Friday December 04, 2009 at 09:06AM

Help

RubyMine and gem bundler don't seem to get along - RubyMine complains that bundled gems aren't attached but these gems aren't available when we try to attach them. Any ideas?

  1. RubyMine uses your gem path so you'll be able to attach to the gem if you add your gem bundler path to your ~/.gemrc file

  2. There's an option to disable this nagging alert in the preferences.

Is there a good Rails plugin skeleton/template out there?

Know of one? Let us know in the comments.

Interesting

  • Don't use sleep 1 or such in before blocks in rspec if you need to ensure a delay between two events. A before block is ran between all nested contexts so you're probably incurring a larger penalty. Instead, you should stub Time.now.

  • One team implemented git commit hooks to facilitate communication - on rebase or merge new messages from a text file in the project root are displayed to alert other pairs to changes such as gem upgrades, noteworthy database changes, etc.

John PignataJohn Pignata
Prevent Cross-site Scripting Attacks with Rails 2.3.5 and rails_xss
edit Posted by John Pignata on Tuesday December 01, 2009 at 06:12PM

Earlier this week, the Rails core team released Rails 2.3.5 which introduces a major new feature: support for automatic cross-site scripting protection via the rails_xss plugin. rails_xss switches the default behavior of Rails to automatically escape all unsafe strings emitted into the view.