Cucumber testing and ssl

Problem

Your application is ussing force_ssl to redirect all calls to ‘https’, but when you try to use your cucumber tests they fail.

Solution

By using the suggestion here, you can add a file in your initializers to bypass the ssl in development and test environment as follows:

module ActionController
  module ForceSSL
    module ClassMethods
      def force_ssl(options = {})
        before_filter(options) do
          if !request.ssl? && !Rails.env.development? && !Rails.env.test?
            redirect_to :protocol => 'https://', :status => :moved_permanently
          end
        end
      end
    end
  end
end

deploy:assets:precompile insists on running on production environment in capistrano

Problem
You want to deploy your rails 3.2 application to another environment except production, but the default capistrano recipe for precompiling the assets keeps using the production environment as in:

 * executing `deploy:assets:precompile'
  * executing "cd /var/www/dev/app/releases/20120816130649 && rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
    servers: ["server.name.com"]

Solution
Add the following environment option in your deploy/other_env.rb file:

set :rails_env, "other_env"