I can see the head!

If a rails app were a baby, the pregnancy would be wonderful and the labour would be a horrible, painful affair with the blood, and the screaming, and the fainting nurses, and the obstetricians working shifts. I’m at the stage now where the head is mostly out, but those wide shoulders are causing everyone a lot of trouble.

What i’m trying to say is – it’s up! At www.reeplies.com. I’ll fix the route for this later so reeplies.com works, but for now it’s best hidden away as it’s pretty broken – basically, gems don’t work. I can’t *install* my own gems on the server – this would be the ideal way. What i need to do is to ‘freeze’ them into local files (that live in the vendors folder) and then copy those files over.

For now, you can add articles, as long as you put the title in (i commented out the bit where reeplies says you can leave title blank). However, if you try and *view* an article, the code breaks because it needs the rmagick gem to show pictures.

Yesterday, James McCarthy gave me way too much of his time trying to get the deployment working. We were having all sorts of problems, with not very much (if any) feedback about what the problems were. The app was just broken. No trace or nothing. In the end, i built up a new app from scratch, following bluehost’s instructions, then made the structure the same as mine (with ./script/generate controller article etc for every controller and model), then replaced all the empty files with my app’s files, doing the same thing for the public folder. And that works, except for like i say, the gems are missing.

Still though, feel massively buoyed by the fact that the damn thing is working in a limited way. I’m confident i can solve the gems problem as well, with james’ help and some forum action – lots of people must have had this exact problem before.

I already tried getting a tar file (destined for *nix surely), copying it over the the app vendor folder via ftp, then untarring it on the server, via ssh – this seemed to work, in that it untarred to the correct place, but the app still crashes.

Next step -after following a tutorial on the bluehost site, i changed my .bashrc file, which lives in the root directory of my allocated folder, by adding the following:

export PATH=”$PATH:$HOME/packages/bin:$HOME/.gems/bin”
export GEM_HOME=”$HOME/.gems”
export GEM_PATH=”$GEM_HOME:/usr/lib/ruby/gems/1.8″

export GEM_CACHE=”$GEM_HOME/cache”

Then, following some forum advice, i typed

source ~/.bashrc

at the command line – this makes the bashrc file get read i think.

After that, i can install gems! Or at least, i could install hpricot, i didn’t try anything else.

However, the app still crashes when i require hpricot.

Looking at another forum post, it may be that the server doesn’t know where to look for them. They are in ~/.gems/gems (where ~ is the root folder)

James with some advice again, pointed me here.

Following this, i do the following. Go to my root and type ‘pwd’ – this gives me


– the location of my root folder. Next, i type

gem environment

and get the following

RubyGems Environment:
– VERSION: 0.9.2 (0.9.2)
– INSTALLATION DIRECTORY: /home/reeplies/.gems
– /home/reeplies/.gems/gems
– /home/reeplies/.gems

Then i make a new file called gemrc in the root directory, and put this into it:

gemhome: /home/reeplies/.gems/gems
– /home/reeplies/.gems
– /home/reeplies/.gems/gems
Next, call

gem environment


RubyGems Environment:
– VERSION: 0.9.2 (0.9.2)
– INSTALLATION DIRECTORY: /home/reeplies/.gems
– /home/reeplies/.gems/gems
– /home/reeplies/.gems

wait – i didn’t change anything! The environment’s the same! Never mind, carry on.

Next, i added the gem paths into environment.rb with this line:

ENV[‘GEM_PATH’] = ‘/home/reeplies/.gems:/home/reeplies/.gems/gems’

I’m guessing that the colon seperates items in a list of paths.

Next step: edit .bash_profile, which is again in the root directory. Added the following lines:

export GEM_PATH=/home/reeplies./gems/gems
export GEM_HOME=/home/reeplies/.gems

WAIT – i’ve been an idiot. I need to include the existing preinstalled gems as well – these are the paths for those:

gems folder is in /usr/lib/ruby/gems/1.8/
gem itself (the program) is in “/usr/sbin

and my local path is ‘/home/reeplies/.gems‘ (i think we miss off the last ‘gems’ as that’s the thing we’re locating).

Lets try again.

nope. OK, let’s try again with the extra /gems added to the paths – so they point to where the individual gems folders are rather than where the ‘gems’ folder is. So, this time

gems folder is in /usr/lib/ruby/gems/1.8/gems/
local path is ‘/home/reeplies/.gems/gems

OK, here we go again…


tried again with

gems folder is in /usr/lib/ruby/gems/1.8
local path is ‘/home/reeplies/.gems/gems

still no luck. arghhh.

james has fixed it, bless him. What a star. It was something to do with not using the nested gems folders after all i think.

made some more progress:

require ‘model_extensions’ ” wasn’t working because i had to copy over model_extensions.rb from my lib folder. Once done, this worked. Next problem was

“require ‘open-uri’ “. Open-uri is a standard component of ‘rubygems’, a list of standard gems usually installed along with rails/ruby, but it’s not in the installed version for some reason. Fortunately, i was able to get it by getting a list of all available gems with

gem list –remote >remote_gems_list.txt

and then doing

gem install ‘rubygems-update’


So, plugin/gem-wise, all i’ve got left is
#include Magick
#gem ‘actionpack-imagemagick’
#require ‘mini_magick’

Next step – did

]# script/plugin install http://opensvn.csie.org/rails_imagemagick_tag/imagemagick_tag/

Which installs imagemagick for rails. Testing – yes, my pictures work! Woohoo! (next stop movies, don’t want to think about that for now though). One problem with the pictures is that the thumbnail’s aren’t showing up. Let’s have a look at that…my local version’s showing them fine, maybe i didn’t set the thumbnail folder up? Nope, the folder is there, and there’s a correctly saved and named thumbnail in there. Let’s have a look at the page source (always a good start for debugging:

<img alt="Missing thumbnail" src="/data/pictures/thumbs/thumbpic1.jpeg?1190030080" />

Ah – see all those digits stuck on the end of the filename? I had that problem before! Argh, what was the solution…i remember getting help on a forum about it. Maybe i blogged it? Right – it’s something to do with the image_cache. It’s not the digits themselves, as my working local version has those as well, when i look in the source.

Found it – i’d commented out the following lines in the deployed version as they were making it crash –

imagemagick_for ‘/data/pictures’, :cache => ‘/data/pictures/cache’


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s