David Goudreau's blog



David GoudreauDavid Goudreau
Standup 12/04/2009
edit Posted by David Goudreau on Friday December 04, 2009 at 09:33AM

Help!

David GoudreauDavid Goudreau
Standup 12/03/2009
edit Posted by David Goudreau on Thursday December 03, 2009 at 09:31AM

Help!

  • Git branch best practices - we have a customer who doesn't do acceptance often enough so we'd like to keep production code in a different branch from demo code. Any suggestions?

    Our friend Josh Susser has a good blog post on git branching workflow. Some other suggestions are to have a separate 'deploy' branch which you cherrypick changes from your 'development' branch with and deploy to production with (this would, however, require a separate integration test process to integrate the cherrypicked changes). Or, of course, round up your customer and have them do acceptance more regularly.

  • RubyMine - some Pivots are having issues running RSpec in their Rails projects.

    The usual steps we take are to make sure you can Command-click the rspec and spec/rails references in your spec_helper.rb and get to the gems they correspond to and to make sure your spec directory is flagged as a test directory in Settings => Project Structure in RubyMine. That didn't seem to solve this particular issue, though. There was some talk about commenting out arbitrary 'require' statements in your files and that change somehow making RSpec run correctly. Strange.

  • Testing paperclip - tests don't behave correctly when running them in RubyMine. There are issues with the 'identify' command.

    A possible issue is that ghostscript is not installed. Paperclip uses ImageMagick which uses ghostscript to identify attachment file types. You can install ghostscript using MacPorts. This can be tough to track down because paperclip appears to just swallow the exception that occurs when using ghostscript. Some other projects are mocking out paperclip in their tests to avoid the issue completely.

  • validates_associated fun in 2.3.5 - it's changed from 2.3.4. Another change is depending on rack 1.0.1

  • You can now boot from ebs on Amazon

  • It appears that ActiveRecord now validates all associated objects by default, for any type of validation. Given this example:

    class User < AR::Base
      has_many :wibbles
    end
    
    
    class Wibble < AR::Base
      validates_presence_of :name
    end
    

    when you save a User, it will validate all associated wibbles and fail validation if any wibble fails validation. This always happens on create, and it appears happens on update if the association is an auto-save association, which it implicitly becomes if you allow nested attribute create/update for the association.

    Before Rails 2.3.4 a failed validation on an association would give you a moderately nonsensical validation error. In the case of the above example, if the name validation failed on an associated wibble then the user would have the error "Name can't be blank," which is, of course, misleading. The attribute name for the error would just be "name", so tests for the validation would be something like @user.should have(1).error_on(:name)

    As of Rails 2.3.4 (possibly 2.3.3) the error message for a validation failure on an associated object changed to include the object type, so if the name validation failed on an associated wibble then the user would have the error "Wibbles name can't be blank." They accomplished this by changing the attribute name for the error to "#{association_name}_#{attribute_name}", thus "wibbles_name". Tests for the validation would have to change to @user.should have(1).error_on(:wibbles_name)

    As of Rails 2.3.5, the error message for a validation failure on an associated object is back to what it was pre-2.3.4 ("Name can't be blank"). However, this is because the attribute name for the error is now "#{association_name}.#{attribute_name}. So, tests have to change again to @user.should have(1).error_on('wibbles.name')

    Not really a huge difference, just an annoyance that it keeps changing.

Interesting Things

  • SMSW - this is an annual supermarket street sweep that benefits the San Francisco Food Bank. Ride on bikes, pick up foodstuffs from supermarkets and win prizes while helping the Food Bank! This Saturday 12/5 at noon.

  • Check out the AAU Future Tense exhibit at 688 Sutter Street Gallery - a showing of art that you can actually pick up with your hands! Exhibit is open thru January.

David GoudreauDavid Goudreau
Standup 12/01/2009
edit Posted by David Goudreau on Tuesday December 01, 2009 at 10:14AM

Help!

  • Heroku logs - how do you get more than 20 lines? Is there an option to get the entire log? Apparently there used to be an option to get the whole thing. Looks like we're not the only ones looking for this.
  • Webrat - is it really as incomplete as it appears? The answer is yes. We've had to create a bunch of the api ourselves to facilitate using it. If you know you're just going to use the Selenium portion of it without the Rails integration option then you might just call the Selenium API directly (which Webrat does make available to you) from your Selenium tests.

Interesting Things

  • Rails XML parameter rudeness - sometimes when only a single model is posted, it does not generate the second array, and instead gives you a hash (i.re. not wrapped in []). This is apparently a well-known bug. Workaround is pretty straightforward:

    widgets = params[:widgets][:widget]
    if widgets.is_a?(Hash)
      widgets = [widgets]
    end
    
  • Movember is over but you can revel in the 'stashes all year long at Pivotal Movember.