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

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

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

Tuesday, April 8th, 2008

Upgrading to Rails 2.0.2 problems/solutions

Problem
Upgrading from Rails version 1.2.3 to version 2.0.2.
Following the suggestion in DH’s weblog here when using sudo gem install rails -y, it gets the trunk version of rails which at the time was 2.0.2.9216.
This causes a few problems and breaks a few more things.
Solution
In order to get back to the latest stable version, you have [...]

No Comments » - Posted in ruby on rails by kosmas

Monday, March 31st, 2008

Regular expression checking of landline/mobile UK numbers in Ruby on Rails

Problem
You want to have validations for phone numbers in Ruby on Rails code.
Solution
The mobile numbers in UK should start with a 0, followed by 7, then a number between 5 and 9, and finally another 8 numbers.
For the landline numbers in UK the number should start with 0, followed by either 1 and 8 or [...]

No Comments » - Posted in ruby on rails by kosmas

Wednesday, March 19th, 2008

Red Box progress indicator with active_scaffold_upload branch

Problem
You need to display a splash screen when uploading files to a Ruby on Rails application.
Solution
My model:
class Number < ActiveRecord::Base
file_column :intro
file_column :vmail
end
The steps I have followed.

Install redbox plugin from project path run:
./script/plugin install svn://rubyforge.org/var/svn/ambroseplugins/redbox

If files redbox.js, redbox.css and redbox_spinner.gif haven’t been copied over to the public folders copy them over manually [...]

No Comments » - Posted in ruby on rails by kosmas