ferret installation error

Problem
Trying to install ferret with sudo gem install ferret fails with the following error:

fs_store.c:300: error: format not a string literal and no format arguments
make: *** [fs_store.o] Error 1
rake aborted!
Command failed with status (2): [make…]

Solution
As the installation was not possible by using the gem install command, the next step was to download the ferret.tar.gz file extract it and try and install the plugin manually.
It also failed with the same error message.
After some googling for the error message it seems that newer gcc versions fail for non critical errors which in this case is caused by the make options -Wformat -Werror=format-security
So if you replace the:
-Werror=format-security
with
-Wno-error

in the extracted folder/ext/Makefile

and then follow the original instructions as in:

$ rake ext
$ ruby setup.rb config
$ ruby setup.rb setup
# ruby setup.rb install

It should be installed correctly.

Pdf with .doc templates using prawn in Ruby on Rails

Problem
You want to generate pdf documents in your Ruby on Rails app using .doc templates.

Solution
Open the .doc document in OpenOffice and save it as an Open Document Format (.odt).

Open the saved .odt document and export to pdf, making sure you use ‘Losless compression’ in the General Options section.

Use imagemagick’s convert to make the pdf file to an image (setting the density to your requirements – default is 72dpi):

convert -density 150 one.pdf one.png

Copy the image one.png to your rails image directory (public/images).

Use the image as a background to the pdf created by prawnto (install plugin if you don’t have it) with:

templ=”#{RAILS_ROOT}/public/images/one.png”
pdf.image(templ, {:position => :center, :vposition => :top, :scale => 0.215})

Put the database field(s) text on position (you’ll have to play around with the coordinates to get it right), like:

pdf.font “#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf”, :size => 9
pdf.text “#{@model_name.fielda_name}”, :at => [100,530]
pdf.text “#{@model_name.fieldb_name}”, :at => [100,510] …

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