Adventures in programming and data.

  • Reducing Rails asset precompile times on JRuby

    Rails asset precompile times on JRuby are considerably slower compared to MRI. I came across this post which provided suggestions on speeding up the asset precompile task. Using the following options – using Node.js instead of therubyrhino for JS compilation, forcing the JVM to 32 bit (although this can be omitted on a 32 bit […]

  • Silencing noise in the Rails development log

    The standard Rails development log contains a lot of noise that is rarely meaningful for debugging. The Quiet Assets gem is a mandatory part of my Rails development process as it removes the logging noise of the asset pipeline. Also, if WEBrick is used as a development server, the following entry is logged for each […]

  • Mixing DatabaseCleaner transaction and truncation strategies

    RSpec by default issues a database transactional rollback that is executed after the completion of a block. When using Capybara with the :js option (to enable testing with Selenium or Webkit), the transactional rollback offered by RSpec is unusable as the browser is loaded via a separate thread and has a separate database connection. Thus […]

  • Mocking instances created via ActiveRecord’s find

    Most Ruby mocking frameworks have the ability to mock a new object created via a constructor. However, when an object is created via ActiveRecord’s find or find_by_* methods, the .new method isn’t invoked. Instead, the .instantiate method is called. For example, to specify :instantiate as the object creation method using FlexMock:

  • Persisting IRB & Rails Console History

    Continuing the theme on customising IRB and Rails Console, add these lines to ~/.irbrc to persist the command history across console sessions:

  • Awesome Print your IRB & Rails Console

    Awesome Print is a Ruby gem that prints prettified objects to the console. To avoid having to prepend ap to all your console commands, set it as the default formatter in IRB and Rails by adding the following to your ~/.irbrc: Obviously, Awesome Print first needs to be installed: gem install awesome_print UPDATE: Awesome Print […]

  • Hello world!

    So I’ve been toying around with the idea of starting a blog and after prodding from my brother and probably more so, finally plonking down some cash for a domain, that was all the encouragement I needed.