patching up

I quietly deployed my Giggle 2 project into its production environment on Friday evening: and once my wife had joined in some testing, I then had a few bug fixes to make!

First I had to sort out the Capistrano deployment script. Due to a misunderstanding on my part, it didn’t create the temporary directories for caching and sessions. I had thought I could put Ruby code in the script and it would run it remotely, but this is not the case – the Ruby parts run locally and only the command strings provided to the run method are run on the remote servers.

Concerning the sessions, I was getting some occasional error messages from the server failing to create session files under /tmp, so I decided to move them to under the application directory. This meant adding a line to environment.rb to say where they were, and editing my cleanup script to match1.

I had various problems with my search cache cleanup script2, which were mostly due to environment differences. First it turned out that it wouldn’t run because of DOS style line endings – it looked like this prevented the shell from interpreting the shebang line correctly. A quick sed script fixed this. Next it didn’t recognise the FileUtils class – I needed to require it to make it work – it looks like this is a difference between Ruby 1.8.4 on my dev machine and 1.8.2 on the server. Finally I had forgotten to check for the case where it tries to delete a directory that is already deleted, so I had to correct that.

I fixed a couple of bugs in the application itself last night. The first was due to caching too much of the Gig detail page, where a different message can be displayed depending on whether the user is logged in and whether they went to the gig.

The second was that the creators of objects were not being linked to them. I implemented a check on the ‘add gig’ page to make sure only logged in users could use it. I also made a small change in the syntax of the models that fixed the linking problem, though I’m not sure quite why it made a difference: something to do with scope I guess. I changed:

def before_create
created_by = User.current_user if User.current_user
end

to:

def before_create
self.created_by = User.current_user
end

There are some other issues with the project to consider, but not things that are stopping it from working.


fn1. I’m using the default file-based session store, which is not generally advised for Rails. However given the performance constraints in the Dreamhost environment I don’t think I’ll be better off with any of the alternatives.

2 I will write an article about the search cache implementation later, to complete my series.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*