@Cybrilla » Blog Archives

Tag Archives: Rails

Rails is a web application development framework


How are gems loaded in a Rails application

Published by:

You add a new gem to your Gemfile and start using it in your application’s code. You never have to do ‘require <gemname>’ to use it in the application.

Ever wondered how rails autoloads all your gems? Let me walk you through the process which rails follow. Actually Rails uses Bundler to handle dependency management of all the gems and also autoload them.

How Rails put the gems “on the load path”?


The file is loaded during the rails initialization process and all it does is load rubygems and run Bundler. This will automatically discover your Gemfile and puts all the gems listed in the load path so that they can be required later. (Note: The gem’s aren’t run at this point, just the load paths are set.)

How are gems required (run) ?


This file includes all the gems listed in the application’s Gemfile by calling Bundler.require. Bundler allows us to specify which groups to automatically require through the parameters to Bundler.require

The above code loads the assets group of gems only in development and test environments. It makes sense as we use precompiled assets in production, hence assets gems aren’t required to be loaded. (see Rails.groups). There are few comments in the file which will help you to change the default behavior if required.

Understanding rails initialization internals allows us to tweak the process to reduce the application load time. We’ll talk more about the process in the coming posts.


What and Why of Rails?

Published by:

For the last few years, there is a lot of excitement going on about Rails among the web developers. Few months back, techies at Cybrilla have decided to give it a try and now Rails is the main development platform. I decided to blog the reasons behind it, so that it helps you to decide if you are planning to get your hands dirty with Rails.


Rails is a web development framework based on Ruby Programming Language. It strictly follows MVC architecture and believes in ‘convention over configuration’ concept.

For developers with Java background: Rails is similar to struts / spring mvc etc.
For developers with PHP background: Rails is similar to CodeIgniter / Zend etc.
For developers with Python background: Rails is similar to django

Rails philosophy:
1. Convention Over Configuration – Every java developer has to face the problem of maintaining endless xml configuration files. Rails removes much of this pain by following certain conventions for file names, directory structures, database column names etc.
2. DRY: Don’t Repeat Yourself – Rails strongly believes that re-writing a same piece of code is a bad thing. Because so many implementation details are implied from a master source, making changes in Rails becomes straightforward and generally requires a change at a single location.
3. REST is the best pattern for web applications – Rails assumes that most of the web applications are/can-be organized around resources and therefore uses standard HTTP verbs extensively.


1. Conventions impose discipline in coding. This allows the developers to concentrate on the core application logic than on setting up the application, setting up the database, configuring database etc. mundane tasks.
2. Because of strong conventions, changes to applications are very cheap and therefore Rails is very strong in agile development space.
3. Great community of rails developers keep on building plugins which can be used for common tasks. This removes a lot of “plumbing” associated with building applications with other frameworks.

Above all, it’s fun developing in Rails, as everyday you get to see a new magic 😛