Archive for May, 2008

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