So far, it\’s RoR

Ruby on Rails, PostgreSQL, SVN, etc….

  • Pages

  • Subscribe

  • December 2007
    M T W T F S S
    « Oct   Jan »
  • Advertisements

Archive for December, 2007

User profiles with restful_authentication

Posted by Chirag Patel on December 22, 2007


Error when updating the user from a form

ActiveRecord::RecordInvalid (Validation failed: Password confirmation can’t be blank, Password is too short (minimum is 4 characters), Password can’t be blank):





It’s probably because of the restrictions on the User model (attr_accessible or attr_protected, in particular). But allowing users access to any part of the User model via mass assignment is dangerous. That’s why many people create a separate Profile model and link it via a 1:1 (belongs_to, has_one) relationship.




Coming soon




Posted in Ruby on Rails | 2 Comments »

Linux commands to install ImageMagick and RMagick

Posted by Chirag Patel on December 19, 2007

This is what I had to do to get it to work on CentOS 5. For some reason, FreeType would not work with yum so I built it from scratch. I’m not sure if the all the “yum install”s were needed, but I did it anyway.

#yum install freetype — did not work

cd /usr/local/src


tar xvzf freetype-2.3.5.tar.gz



make install


yum install glib
yum install glib2
yum install libpng
yum install libjpeg
yum install libtiff
yum install ghostscript
yum install freetype


cd /usr/local/src


tar xvzf ImageMagick.tar.gz

cd ImageMagick-X.Y.Z

./configure –disable-static –with-modules –without-perl –without-magick-plus-plus –with-quantum-depth=8 CFLAGS=-fPIC


make install



tar zxvf RMagick-1.15.11.tar.gz

cd RMagick-1.15.4


export LD_LIBRARY_PATH=/usr/local/lib



make install



#test Rmagick in Rails

root# ruby script/console

irb(main):001:0> require ‘RMagick’

irb(main):002:0> include Magick

=> Object

irb(main):003:0> img = “test.jpg”

=> [test.jpg JPEG 10×11 DirectClass 8-bit 391b]

irb(main):004:0> img.write “test.png”

=> [test.jpg=>test.png JPEG 10×11 DirectClass 8-bit]



Posted in Linux, Ruby on Rails | Leave a Comment »

“Multiple default values” migration error with PostgreSQL 8.2.5

Posted by Chirag Patel on December 16, 2007

PostgreSQL 8.2.5 error

== CreateHeartrates: migrating ================================================

— create_table(:heartrates)

NOTICE: CREATE TABLE will create implicit sequence “heartrates_id_seq” for serial column “”

rake aborted!

PGError: ERROR: multiple default values specified for column “id” of table “heartrates”

: CREATE TABLE heartrates (“id” serial primary key DEFAULT NULL, “user_id” integer DEFAULT NULL, “timestamp” timestamp with time zone DEFAULT NULL, “heartrate” smallint NOT NULL)




I don’t see the above error on my Lenovo Windows machine because it’s running PostgreSQL 8.2.4. The issue occurs with PostgreSQL 8.2.5


Add this to the create table migration


t.column :id, :primary_key, :null => false



This is probably the simplest way to deal with this defect.



Post from: Migrations and PostgreSQL Primary Keys) – Rails Trac – Trac:

I tried to find a good place to patch the code, but everywhere I did, I could easily imagine someone yelling, “you can’t touch that”!


For instance, if scheme_definitions.rb’s primary_key could set :null => false, then everyone should be happy, even other db’s. Except, that of course you change all db’s to ‘NOT NULL’ versus ‘DEFAULT NULL’. I don’t know why you’d want to say ‘DEFAULT NULL’ though, it seems vaguely wrong.


This seems to be still in rails 2.0 too, and is still in 1.2.6.


Posted in PostgreSQL, Ruby on Rails | Leave a Comment »