Installing REE with rbenv with iconv support and Homebrew

December 28, 2011 — 0 Comments
Tagged with: ruby rvm libiconv rbenv iconv

I picked up a new Mac Mini recently and have been experimenting with rbenv instead of RVM. For some reason, one of my projects was giving me the following error when attempting to start the project (through the Rails console and through pow as well).

  
    ...action_controller/cgi_ext/stdinput.rb:14:in `included': undefined method `alias_method_chain' for CGI:Class (NoMethodError).
 

This error comes up when the Ruby version that you’re using isn’t compiled with iconv support. With rbenv, you can compile iconv support with the following command:

  
    CONFIGURE_OPTS="-c --with-iconv-dir=/usr/local/Cellar/libiconv/1.14" rbenv install ree-1.8.7-2011.03    
 

I should note that I lost quite a bit of time trying to target libiconv with version 1.13. I don’t know if this is a problem with libiconv 1.13 or it was something with my specific version, but once I upgraded to version 1.14, I was able to make it work.

Building that Pesky Nokogiri Gem When Using Homebrew

August 22, 2011 — 0 Comments

I’ve encountered the following error (and those like it) many, many times when setting up existing projects that use Nokogiri in conjunction with Homebrew. Every single time I encounter it, I have to sort through my history to try to find out how I solved it.

So this post is as much a reminder to myself as it is to other people experiencing the same issue.

When attempting to install the Nokogiri gem you might get an error similar to this:

  
Installing nokogiri (1.4.4) with native extensions 
/Users/carlos/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/site_ruby/1.8/rubygems/installer.rb:551:in `build_extensions': 
ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/Users/carlos/.rvm/rubies/ree-1.8.7-2011.03/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
 

Here are the instructions that I use to solve the issue:

  
    brew install libxml2
    brew install libiconv
    brew link libiconv
 

Using Rack-Test and RSpec to Test a RESTful API in Rails 2.3.x

August 07, 2011 — 2 Comments

I recently started writing a RESTful API using rack-test for an existing Rails 2.3.11 application, but I noticed the documentation didn’t really go into setting it up for a Rails 2.3 project.

Here are some simple steps to get it going.

In my spec helper file, I wrote the following module:


module ApiHelper
  require 'rack/test'
  include Rack::Test::Methods

  def app
    ActionController::Dispatcher.new
  end
end

Then I can use include the ApiHelper in all of my API specs and write code like:

  
require 'spec_helper'
include ApiHelper

describe 'API Authentication' do
  it "should return json errors with no token" do
    get '/api/tasks.json', :token => ''
    error = { :error => "Token is invalid." }
    last_response.body.should eql(error.to_json)
  end
end    
 

For more examples on building a RESTful API using RSpec, I highly recommend checking out Ryan Bigg’s Ticketee project for his forthcoming Rails book, Rails 3 in Action

Feeds

Last Read

Steve Jobs Anything You Want A Clash of Kings (A Song of Ice and Fire, Book 2) A Game of Thrones: A Song of Ice and Fire: Book One

Last Heard

Spartacus: Blood And Sand Warp Riders Black Swans And Wormhole Wizards Assassin's Creed Brotherhood (Original Game Soundtrack)

Last Watched

Star Wars: The Clone Wars: The Complete Season Three [Blu-ray] Horrible Bosses Green Lantern (Three-Disc Blu-ray/DVD Combo + UltraViolet Digital Copy) Tucker & Dale Vs Evil [Blu-ray]

Last Played

Battlefield 3 Batman: Arkham City Forza Motorsport 4 Dead Island


You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser