26 juin 2009

ArgumentError after upgrade to Rails 2.3.2

If you get error:

ArgumentError: wrong number of arguments (3 for 0)

in your tests after upgrading to Rails 2.3.2, maybe you have a method called find_layout that determines the layout to use?

If so, change the name to something else (I named mine my_layout) and magic, it works.

It must be a name conflict somewhere in the new Rails...

Rails assets and Apache SSL

In a current project, I use calls to assets.mycoolsite.com to improve load times. However, we only have one server with one IP address, so ultimately all calls point to the same IP address.

This becomes important when you start using SSL. Unfortunately, Apache cannot recognize 2 different NameVirtualHost at the same IP address in SSL mode... Bummer!

Rails to the rescue!

  1. Install Asset hosting with minimum SSL from his majesty DHH himself:
    script/plugin install git://github.com/dhh/asset-hosting-with-minimum-ssl.git

    (Warning though: it requires a version of Rails > 2.2, so you have to be ready to upgrade: see README for more details)
  2. In production.rb:
    config.action_controller.asset_host = AssetHostingWithMinimumSsl.new(
    "http://assets%d.example.com", # will serve non-SSL assetts on http://assets[1-4].example.com
    "https://assets1.example.com"  # will serve SSL assets on https://assets1.example.com
    )