Display customize column name in ActiveRecord validation

There are number of ways to set custom column name ,

But i generally preferred following .

HUMANIZED_ATTRIBUTES = {:p_type=> "Advertise type", :body=>"Description"}

def self.human_attribute_name(attr)
HUMANIZED_ATTRIBUTES[attr.to_sym] || super

Now we can set custom column name , good to go.


Upgrade php centos

Remove the existing php version:

yum remove php php-*

Install php53 versions referring to the previously saved list. The names are the same except that instead of the prefix “php” you have “php53″:

yum install php53 php53-cli php53-devel php53-gd php53-mbstring php53-mysql php53-pdo php53-xml php53-xmlrpc php-pear

Rails ActionMailer Setup with Yahoo SMTP setting

Code kept throwing”Errno::ECONNRESET (Connection reset by peer):’ error whenever I tried to connect to yahoo’s smtp server and send a message. It took me a while to figure what the problem was: Yahoo suggest me to use port 465; but the correct port number to use is 587!

So to save you couple of hours filled with frustration and hair pullings, here’s the action_mailer setup that works:

ActionMailer::Base.default_charset = "utf-8"
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "smtp.bizmail.yahoo.com",
:port => 587,
:domain => "www.your-domain.com",
:user_name => "username@your-domain.com",
:password => "some-password" ,
:enable_starttls_auto => true,
:authentication => :plain

How to install RMagick Gem on Linux/Ubuntu

How to install RMagick Gem on Linux/Ubuntu

While installing RMagick on Linux, if you are getting errors like this
“GraphicsMagick-config… no configure: error: Can’t install RMagick. Can’t find Magick-config or GraphicsMagick-config program. …”,
below is the solution for this error.

RMagick requires ImageMagick and which further requires loads of dependencies already available to get installed and work properly. I was figuring out of those all, and thank god got a quite simple and elegant way to do all that in just three commands.
First you will have to install imagemagick then libmagick9-dev and then finally you can install rmagick.

sudo apt-get install imagemagick
sudo apt-get install libmagick9-dev
sudo gem install rmagick

for debian
if ask for MagickCore library , search find / -name MagickCore.pc

yum install ImageMagick-devel
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig gem install rmagick

Source : http://expressica.com/2007/07/04/how-to-install-rmagick-gem-on-linuxubuntu/