Tatva-Artha

meaning of "it"

Archive for the ‘rails’ tag

Rails Constants: Location matters

without comments

Rails framework provides a standard location for defining application specific constants. All default constants go in constant/environment.rb and any environment specific overrides go in config/environments/<env>.rb file. Normally, any constant that is overridden in environment specific file takes precedence. However, there is a catch. If a constant is defined outside of Rails::Initializer.run block then it overrides all other definition preceding it.

Hence, when defining constants in default config/environment.rb file, beware:

require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
A_CONSTANT = "value"
end
# Do not define environment specific constants here.

Enjoy!

Written by admin

June 1st, 2009 at 9:42 pm

Posted in All, Technology

Tagged with ,

ActionMailer, GMail and TLS

with one comment

Prior to rails 2.3.2, if you needed to use GMail as your SMTP carrier (sending out emails from your app), you had to use one of the following plugins to modify the ActionMailer::Base class to support TLS for ActiveRecord.

  • tlsmail
  • ambethia-smtp-tls
  • openrain-action_mailer_tls
  • simplificator-tls-support

In rails 2.3.2, this is supported natively, provided you had proper configuration specified:

config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'localhost.localdomain',
:authentication => :plain,
:user_name => "username",
:password => "password"
}

This should work without any plugins/gems in rails 2.3.2. The only caveat is that ruby version has to be >= 1.8.7. It won’t work with ruby 1.8.6 or older, as documented here.

Enjoy!

Written by admin

May 4th, 2009 at 9:23 pm

Posted in All, Technology

Tagged with ,

Installing passenger/mod_rails on CentOS

without comments

Installing passenger/mod_rails on CentOS sometimes is not as simple as:


$ gem install passenger
and
$ passenger-install-apache2-module

In my case, I also had to install “apr-util-devel” yup package. Also, for some reason the “sudo yum install ” didn’t work for me. I actually had to become root and then perform install.


$ sudo su -
$ yum install apr-util-devel

After this, “gem install passenger” and passenger-apache module install worked fine.

Written by admin

May 4th, 2009 at 9:16 pm

Posted in All, Technology

Tagged with ,

Installing mysql gem on CentOS

without comments

Installing mysql gem on cent-os may sometimes be not as easy as:

$ gem install mysql

It may result in compilation error and fail to install. While this may happen for various reasons, in my case, I had to install “mysql-devel” package.

$ sudo yum install mysql-devel

Once I did this, the mysql gem installed happily.

Written by admin

May 4th, 2009 at 4:26 pm

Posted in All, Technology

Tagged with ,