If you run into this problem, which by the way usually happens after upgrading the rubygems package (in my case it was to version 1.8.21), your best bet is to upgrade the gem from the backtrace of this error. In my case it was the old passenger version 3.0.9, which was causing this problem. Upgrading to 3.0.11 solved it.
Archive for the ‘rails’ Category
Uninitialized constant Gem::Deprecate
Monday, April 2nd, 2012Tell bundler to install gems globally when using capistrano
Saturday, October 8th, 2011Seems like it’s not so straightforward. Here’s the excerpt from my config/deploy.rb:
require "bundler/capistrano" set :bundle_dir, "" # install into "system" gems set :bundle_flags, "--quiet" # no verbose output set :bundle_without, [] # bundle all gems (even dev & test)
Maybe someone finds it helpful.
Bug of the day
Wednesday, September 28th, 2011Completely bad code follows, beware.
Silent error in Ruby 1.8.7:
x = [:a, :b] => [:a, :b] x.slice!(:a) => nil x => [:a, :b]
Explicit error (resulting in a failing test) in Ruby 1.9.2:
x = [:a, :b] => [:a, :b] x.slice!(:a) TypeError: can't convert Symbol into Integer
Just yet another incompatibility, but for the better!
Run guard-jasmine-headless-webkit without X server
Friday, September 9th, 2011You write specs for your javascript, right? If not, you really should.
jasmine-headless-webkit really helps with that. guard-jasmine-headless-webkit makes it all even more enjoyable, although there’s one caveat – it’s not so easy to set it all up.
There is a great guide for that, but it lacks some important details on running guard-jasmine-headless-webkit without graphical interface (X server).
Assuming you already have Xvfb installed, execute this command to run Xvfb in the background:
Xvfb :0 -screen 0 1024x768x24 > /dev/null 2>&1 &
And then you need to setup the DISPLAY shell variable in order for guard-jasmine-headless-webkit to automatically connect to our virtual frame buffer. Here’s the excerpt from my .bash_profile (it first checks if there is Xvfb running on display :0 and only then sets the DISPLAY variable):
xdpyinfo -display :0 &>/dev/null && export DISPLAY=:0
hookup is the shit!
Monday, June 6th, 2011This is simply amazing:
$ g pull Already up-to-date. $ g co edge Switched to branch 'edge' == AddFileTypeToSong: migrating ============================================== -- add_column(:songs, :file_type, :string) -> 0.0048s == AddFileTypeToSong: migrated (0.1380s) ===================================== $ g rebase master Current branch edge is up to date. $ g co master Switched to branch 'master' == AddFileTypeToSong: reverting ============================================== -- remove_column(:songs, :file_type) -> 0.1674s == AddFileTypeToSong: reverted (0.1679s) =========================
Oh, and it will bundle automatically for you as well, so don’t hesitate and hookup your Rails project!
On Heroku
Monday, February 21st, 2011While Heroku is nice and all, it suffers from the same disease as every other hosted-for-you solution:
$ git push heroku (...) -----> Gemfile detected, running Bundler version 1.0.7 (...) $ bundle --version Bundler version 1.0.10
It’s a whole three patch versions behind! Now I don’t really know (and maybe don’t even really want to know) what has changed between .7 and .10, but I can easily imagine things braking precisely because those minor inconsistencies in Bundler versions.
And sure, I could downgrade to .7, but to do that just because of Heroku? Thank you, but no. I want to ride the latest.
Mocha. The stubbing library
Tuesday, May 26th, 2009This example (shortened here):
class Order
def shipping_cost
total_weight * 5 + 10
end
end
require 'test/unit'
require 'rubygems'
require 'mocha'
class OrderTest < Test::Unit::TestCase
# illustrates stubbing instance method
def test_should_calculate_shipping_cost_based_on_total_weight
order = Order.new
order.stubs(:total_weight).returns(10)
assert_equal 60, order.shipping_cost
end
end
and this snippet (emphasis mine):
The more interesting discussion deals with whether to mock or stub your database-backed model. One upside is speed: This test case will not hit the database at all. Another is independence. I completely isolate the code under test to the controller layer.
convinced me that there just might be some treasure to be found beyond the Test::Unit. And I know that it's just the tip of the iceberg.
Rails and Merb together
Wednesday, December 24th, 2008Or putting it in another words: Merb will be merged into Rails to become Rails 3.0. Is it 1st April just way too soon or what? – was my first thought the moment I’ve read it on the Ezra’s blog. But then I’ve read the official announcement and… it kind of turned out to be true. Surprised I was, definitely. I haven’t really jumped on the whole Merb bandwagon. Sure, I was planning to try out Merb in the (rather distant) future. Now it seems I won’t have to. Merb supposedly did lots of things better than Rails (modularity, less dependencies, more lightweight, faster) and those things are to be incorporated into Rails. Will see how this pans out.
Exciting times. Definitely exciting. Nice Xmas gift.
Rails helpers. Rediscovered
Saturday, April 5th, 2008Normally, you’d use partials to manage some common functionality in a single file. For example like this:
Somewhere in your view:
<%= render :partial => 'ads/ad', :locals => {:placement => 'frontpage-banner1'} %>
It’s quite concise, but how about making it even less verbose? Helpers to the rescue:
module AdsHelper
def ad(placement)
render :partial => 'ads/ad', :locals => {:placement => placement}
end
end
And now you can write this in your view:
<%= ad 'frontpage-banner1' %>
Nice! I believe it’s as short as it gets. Sure, if you render this partial only a few times it might not be worth it, but what if you render it 20 or 30 times?
content_tag FTW!
Thursday, April 3rd, 2008About those one-liners… How about turning this:
<% if logged_in? then %> <p><%= link_to 'Edit', document_edit_path(@document) %></p> <% end %>
into this:
<%= content_tag 'p', link_to('Edit', document_edit_path(@document)) if logged_in? %>
I don’t know about you, but to say that I’m impressed would be not enough. Available from Rails 2.0 upwards.
Entries