Author Archive

Wednesday, July 16th, 2008

Developing in Rails 2.1 and deploying in Rails 2.0.2 (or error - undefined method time_zone)

Problem
You are developing on the latest version of Rails (2.1), but your production server for deployment uses version 2.0.2 (as dreamhost is using at the moment).
Solution

First change the environment.rb file to use the rails version in your deployment server
RAILS_GEM_VERSION = ‘2.0.2′ unless defined? RAILS_GEM_VERSION

You should probably be geting the error: undefined method = time [...]

No Comments » - Posted in ruby on rails by kosmas

Wednesday, June 11th, 2008

Ruby on Rails email scheduling using runner and cron

Problem
You want to send emails from a Ruby on Rails application, when there is a specific condition on a database table. If the database table gets modified by another application outside Rails you cannot use an observer model.
Solution
We already assume that:

You are using a database
You have a model named voicemail (id, number_id, audio, created_at, updated_at)
You [...]

1 Comment » - Posted in linux, ruby on rails by kosmas

Wednesday, May 28th, 2008

Rails 2 new ways

Problem
To get used to the new ways of working with Rails 2.
Solution
Here are some of the new ways of doing things in Rails 2.

Create a scaffold and migration on one step:
./script/generate scaffold product fied1_name:string field2_name:string field3_name:float
Make sure that you don’t have any previous migration(ie manually created) for the same model, as the generator [...]

No Comments » - Posted in ruby on rails by kosmas

Saturday, May 24th, 2008

Upgrading Ruby on Rails application from 1.2.3 to 2.0.2

Problem
Upgrading an existing Ruby on Rails application from 1.2.3, to 2.0.2, presents few problems. I will try and keep a record of the ones I encounter along the way, here.
Solution

Change the config/environment.rb to let the application know to use the 2.0.2 gem rail version,
change the following line from:
RAILS_GEM_VERSION = ‘1.2.3′ unless [...]

No Comments » - Posted in ruby on rails by kosmas

Tuesday, May 13th, 2008

Dreamhost passenger (mod_rails) announced

Today, there was an announcement about Dreamhost, having the new Passenger (mod_rails) feature ready for use with Ruby on Rails applications.
The full announcement is here.
It should be changing the way Rails applications are deployed, making it much easier.

No Comments » - Posted in linux, ruby on rails by kosmas

Thursday, May 8th, 2008

Google Analytics UID

Problem
You want to find out your UID for a specific domain that you have set up with google analytics.
Solution
When you first create the tracking code for your website, it’s quite obvious how to get the UID for that specific website.
If you decide later on to change your site, from drupal to wordrpess for example, it’s [...]

No Comments » - Posted in linux by kosmas

Wednesday, May 7th, 2008

ruby incorrect encoding of pound sign(£)

Problem
You want to pass the £ sign to an http service, but the ruby CGI.escape encodes it incorrectly.
Solution
After using ruby’s CGI.escape for the string as:
sms_msg_tmp=CGI.escape(sms_code)
then replace the encoding with the pound sign encoding as in:
sms_msg=sms_msg_tmp.gsub(’%C2%A3′,’%A3′)
It should then pass the correct value for the £ sign.

No Comments » - Posted in linux, ruby on rails by kosmas

Wednesday, May 7th, 2008

Disabling rails web site when using mongrel,Apache,capistrano 1.4.1

Problem
You want to disable your rails web site for maintenance, but your application uses an older capistrano version than the one currently installed.
Solution
According to the RubyOnRails Cookbook recipe 13.12, it should only be a case of running cap disable_web (enable_web).
But in the meantime you have upgraded your capistrano version to version 2, and started using [...]

No Comments » - Posted in ruby on rails by kosmas

Thursday, April 24th, 2008

git: fatal error: `chdir’ failed: permission denied.

Problem
Trying to use the heroku gem to clone a project and do local modifications I got the following error:
git: fatal error: `chdir’ failed: permission denied.
Solution
It turns out that in Mandriva, when using:
sudo urpmi git
what gets installed is the ‘GNU Interactive Tools’ that has nothing to do with the git version control system.
So make sure you [...]

No Comments » - Posted in linux, ruby on rails by kosmas

Wednesday, April 23rd, 2008

Ext.ux.grid has no properties error

Problem
Trying to use ExtJS with RubyOnRails on Heroku, gives the following error and a blank page in Firebug.
Ext.ux.grid has no properties

Line 141
Solution
In Heroku, you will probably have to manually upload the files from the ExtJS library, as well as the ext_scaffold plugin.
When you do that, two files that ext_scaffold needs, and which they should be [...]

2 Comments » - Posted in ruby on rails by kosmas