Rails scaffold, create .haml rather than .erb views

After being tired of refactoring .erb files to .haml I headed for a way to modify the rails generator that will create .haml view files rather than .erb view files.

After a while, I found what exactly I needed. ‘haml-rails’ is the name of the solution. This is how you do it.

Add the following line to your Gemfile:

gem 'haml-rails'

Then run the bundler (bundle install).

Now append the following lines in your application.rb file (at the end of Application class):

config.generators do |g|
   g.template_engine :haml

That’s it. Your new scaffolds will generate .haml files (and obviously haml syntaxes) for you.

This is much easier than Haml-scaffold.

Extending or replacing core classes in CodeIgniter 2x

It has been quite some time that CodeIgniter 2x has been released after a quite long waiting. There are several improvements in this latest release and upgrading from the 1x is quite easy. However, they have changed some file/folder organization in this latest release. I found these changes as good as it provides better application wise personalization. CodeIgniter’s previous file/folder structures were not (at least, by default) very good (without some/little modification) for hosting multiple application based on single core installation. However, in this version they organized it better.

On of the major change was made in this version in replacing and/or extending core classes. There was no note in their upgrade guide (but explains in their relevant doc page, which I found later). So I had to go through little trouble with it until Arafat Rahman helped me out!

However, the process is simple. In version 2x, they have introduced a new directory called ‘core’ (along with few others). All core classes that needs to be replaced or extended should be in this directory. I liked it very much, as I hated to put core classes in library directory in older versions.

Replacing a core class
Let’s say we want to replace a core class by our own version. Also let’s assume we want to replace the model class (actual name is CI_Model). Now follow these steps:

  • Create a directory named ‘core’ in your application directory, if it does not exist. If your application directory is default one, it would be ‘application/core’
  • Create a new file named Model.php.
  • Put the following line in the newly created empty file:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
class CI_Model
 function __construct()

Now when you create model classes in current application extend the CI_Model as you were doing earlier, this class will be extended rather than the CI_Model class in the system/core/Model.php. However, when you do, think if you have enough reasons to replace the core class as you can do most, if not all, of the tasks by simply extending it.

Extending the core class

Rather than replacing, I find it much better to extend the core class and use that class in my application. The steps of extending the core class are also simple. Continue reading →

Are we ready with Internet Payment systems in Bangladesh?

On 8th June 2010, I have written a blog about the Introduction of Internet Payment in Bangladesh by Dutch Bangla Bank. On 3rd June 2010, they have introduced Internet Payments system in Bangladesh through their gateway where they could process Nexus, Visa and Master Cards. Along with international cards they could process cards those are valid only in Bangladesh. That was a great lift for our e-commerce.

However, as DBBL changes engine while they run, they are possibly unable to attract the market. As a result, 2 days ago Brac Bank also introduced  internet payment and they also saying they are first time in country. What a fun even in front of governor who also endorse same! Continue reading →

My two months experience with Macbook Pro

On July 11, 2010, I have purchased Macbook Pro from Aloha iShoppe! The main intended uses were developing iPhone application and getting more battery backup. I was excited seeing its look and feel! However, I was experiencing problems as soon as I started using it. I considered that as normal. Any new systems takes a while a adopt. But after about two months, I believe, problems are not decreasing! It significantly reduced my productivity. And no doubt I started hating Apple and its products. I hate it mostly specially for leeching my general computing habits! The daily problems I face with it are:

Continue reading →

Technical session on ‘Facebook Application Development’

Yesterday evening, I have participated in a technical session titled “Facebook Application Development” at BASIS SoftExpo 2010. The session was taken by legendary PHP engineer and founder of Leevio, an Social Networking RnD startup, Hasin Hayder.

During the session, the speaker has tried to elaborate the fundamental steps of facebook application development that will show the light to the novices those are interested about facebook application. He also showed ,step by step, a sample facebook application development process.

The whole session was entertaining and useful.

The presentation slide can be downloaded from his blog or directly by clicking here.