RubyGem version error: rack(0.3.0 not ~> 1.0.0)

Problem
Trying to deploy in dreamhost with capistrano you get the error:

RubyGem version error: rack(0.3.0 not ~> 1.0.0)

Solution
Log in with ssh to your dreamhost account and then install the newer version of rack that is not yet installed in dreamhost:

gem install rack

That assumes that you have followed the instructions for setting up your local gems in dreamhost (here) and you already have a ~/username/.gems directory.

You may probably need to also add the following to your config/environment.rb :

ENV[‘GEM_PATH’] = ‘/home/USERNAME/.gems’

Note 09-Sep-2009
It seems that according to the dreamhost wiki we need to add the following to the config/environment.rb, instead of the line above:

if ENV[‘RAILS_ENV’] == ‘production’
ENV[‘GEM_PATH’] = ‘/home/USERNAME/.gems’
require ‘/home/USERNAME/.gems/gems/rack-1.0.0/lib/rack.rb’
end

to use the locally installed rack-1.0.0 gem, instead of the rack installed by dreamhost.

Mandriva – Eclipse – Aptana RadRails

Problem
You want to do a new installation of Aptana RadRails IDE in Mandriva as an eclipse plugin.

Solution

  • Install eclipse first (selecting openjdk when prompted):
    sudo urpmi eclipse
  • According to the instructions here take the following steps:
  • From the Help menu in Eclipse, select Software Updates
  • Select the Available Sotware tab
  • Click the “Add Site..” button.
  • Specify the Location Url update site: http://update.aptana.com/update/studio/3.4/ and click OK
  • Select the checkbox next to the added update site.
  • Click the install button.
  • Complete instruction to install from update site and restart eclipse
  • Go to ‘My Aptana’ page and then the ‘Plugins’ tab on the top
  • Click on Aptana Rad Rails ‘Get It’ link and get through the next sequence of screens select ‘ok’.
  • Restart Eclipse and RadRails should now be installed.

undefined method `render_component’ with ActiveScaffold and Rails 2.3.2

Problem
When using a nested (or embedded) scaffold in ActiveScaffold with Rails 2.3.2 you have the error:

undefined method `render_component'

Solution
According to the issue here, in Rails 2.3 the render_component has been removed.

Install the render_component from:

script/plugin install git://github.com/lackac/render_component.git -r rails-edge

and restart your server, and it should be working.

undefined method `cache_template_loading=’ for ActionView::Base:Class

Problem
While developing on Rails 2.3.2 you want to deploy in dreamhost that uses 2.2.2 at the moment.

Solution
Although we could try to freeze the specific rails version we are using, it’s probably easier as a temporary solution, until dreamhost upgrades the rails version to do the following:

  • Make sure that we have the following line with the appropriate version of
  • RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION

    in the config/environment.rb file

  • Rename the application_controller.rb file back to application.rb
  • Comment out the following line from config/environments/production.rb
  • config.action_view.cache_template_loading = true

Spree installation error in Mandriva.

Problem
You are trying to install spree from the git source, following the instructions from here, but there are errors like:

gem install activemerchant --version "= 1.4.1"      
ERROR:  While generating documentation for builder-2.1.2
... MESSAGE:   Unhandled special: Special: type=17, text=""
... RDOC args: --ri --op /usr/lib/ruby/gems/1.8/doc/builder-2.1.2/ri --title Builder 
    -- Easy XML Building --main README --line-numbers 
    --quiet lib CHANGES Rakefile README doc/releases/builder-1.2.4.rdoc 
    doc/releases/builder-2.0.0.rdoc doc/releases/builder-2.1.1.

Solution
Make sure you have the following gems installed:

sudo gem install builder haml echoe

and then run:

sudo rake gems:install

Mandriva – Rails 2.3.2 – mysql gem – ‘ERROR: Error installing mysql’

Problem
You are trying to install the mysql gem in Mandriva, but it fails with error messages:

ERROR:  Error installing mysql:
ERROR: Failed to build gem native extension...
checking for mysql_query() in -lmysclient... no ....

Solution
After searching in google, with solutions about providing different options (– –with-mysql-config, ..etc), even trying different combinations for providing the client library path, the configuration file, or the header file path, was still faced with the same error installing the mysql gem.
As the Mandriva installation was quite new, it turns out to be a couple of missing packages.
So try:

urpmi gcc
urpmi make

and run:

gem install mysql

again.

It should work out ok install the gem and output:

Building native extensions. This could take a while...
Successfully installed mysql-2.7
1 gem installed

Upgrading to 2.3.2 – Uninitialized constant ApplicationController

Problem
Upgrading from a previous version of Rails to the latest 2.3.2, you get an error:

NameError: uninitialized constant ApplicationController

both in the web browser and in console.

Solution
Since the introduction of Rails 2.3 the application.rb file has been renamed to application_controller.rb.
So in order to solve the problem just rename your file application.rb to application_controller.rb.

Thanks to the post here

Using ActiveScaffold in Rails 2.2 after using default scaffolding

Problem
You want to use ActiveScaffold in Rails 2.2, in a model that you have created using the standard Rails scaffolding script.

Solution

  1. Install the ActiveScaffold plugin:
    script/plugin install git://github.com/activescaffold/active_scaffold.git -r rails-2.2
  2. In your layout (model or application for all models) add the following:
    <%= javascript_include_tag :defaults %>
    <%= active_scaffold_includes %>
  3. In your controller file delete all the standard scaffolding code and add one line, so that your new controller should look like:
    class SomethingsController < ApplicationController
      active_scaffold :something
    end
  4. To configure a RESTful scaffold add the following to your route.rb file:
    map.resources :somethings, :active_scaffold => true
  5. Delete the views that were created from the standard rails scaffolding in the views/somethings folder (edit, show, index ...)
  6. Restart your server

You should now have an active scaffold for your model.