Wednesday, 25 May 2011

Testing your email notifications with MailCatcher.

    Often its hard to test email notifications sent from our application. MailCatcher is a gem which helps you to check those mails sent from your application.
Install the gem as 'gem install mailcatcher' and run 'mailcatcher' on your console. This  will start two servers. One smtp server(on 1025 port), use this server to sent mails. Another server, web server, helps us to view the 'sent' email on our browser 'http://localhost:1080/'. I tested it on Chrome 5.

Tuesday, 24 May 2011

Art of Light: plugin for loading application constants in rails.

Art of Light: plugin for loading application constants in rails.

plugin for loading application constants in rails.

I have created a simple plugin which could be helpful in your rails projects. It is available at . This plugin, once installed , loads constants from a config file, while the application gets initialized (server start/restart, rails console etc ...). 

There will be situations when application specific constants are required in our application. Which we could configure as needed.

This plugin helps to load values from a config file(yml) file based on the 
environment, with out writing extra code. ie: if you have a config file as 'app_config.yml' and has values in it as title: 'Caption'.The plugin helps you to call as "AppConfig::TITLE". If your config file name is 'ror_values.yml' then the values can be accessed as RorValue::TITLE". In short ::.
I have tested against ruby 1.9 and rails 3.0

How to use:
  1. Install the plugin.
  2. This will create a folder 'app_config' inside 'config' folder of your rails application.
  3. A mock config file, named 'app_config.yml', will be created with sample data.
  4. User can edit the file with proper values.
  5. The file name can be renamed
  6. Based on the file name the namescope will be created to access the values( :: ).
  7. Restart the server if you change the file name.
  8. You can expect helpful error messages being raised on invalid access.
  9. When you un-install the files in config/app_config/* will be retained, 
  10. expecting that it would contain useful data. You can manually delete it if needed.

    I have tested it against rails 3.0.x and 2.3.8 .