Ruby on Rails


Ruby on Rails blog containing tips, tricks and tutorials. Great for both novice and experienced web developers.

view:  full / summary

Controllers for the Devise Gem

Posted by Jamal Nasir on November 27, 2012 at 8:40 AM Comments comments (1)

The devise gem is a superb gem for authentication. It has a nifty generator for views and other things, but it doesn't have any generator for controllers. So, here in this post I will show you how to get the devise's controllers.

The controllers for the devise reside in it gem location. To import those controllers to your application edit the following command according to your system and then run it. Suppose you are in the application directory.

cp -R &...

Read Full Post »

Authentication and Authorization in Rails Using Devise and CanCan

Posted by Rq Bukhari on April 29, 2012 at 5:30 AM Comments comments (0)

Are you tired of spending lot of time creating user authentication systems. Are you tired of creating a system to manage different roles of users. There are many useful open source stuff available. Devise and CanCan are my choice for user authentication and authorization.

Devise and CanCan are customizable and easy to use. You don't need to spend lot of time on user a...

Read Full Post »

Devise Authentication (Update record without providing current password)

Posted by Rq Bukhari on March 7, 2012 at 1:30 AM Comments comments (2)

In this post I'm going to introduce devise authentication in ruby on rails. Devise is a full-featured authentication solution for your application. It handles all the controller logic and views. To learn how to use devise there are many tutorials, screen casts av...
Read Full Post »

Filtering Parameters

Posted by Jamal Nasir on March 1, 2012 at 6:05 AM Comments comments (1)

If you have some sensitive data in parameters and you want to hide it from the request log. Then one of the way is to use filter_parameter_logging in a controller where these parameters are expected.


filter_parameter_logging param1, param2

Read in detail.

Show Branch name in Terminal

Posted by Jamal Nasir on February 14, 2012 at 8:50 AM Comments comments (1)

If you switch branches oftenly and you don't know in which branch you are in currently. Then run the following

lines in the terminal which will show you the current branch name...

source /etc/bash_completion.d/git
PS1='\[$(tput setaf 3)\]\[email protected]\h:\[$(tput sgr0)$(tput setaf 5)\]\w\[$(tput sgr0)$(tput setaf 2)\] $(__git_ps1 "[%s]") \[$(tput sgr0)\]$ '

Calculate the Last Day of Month with Ruby

Posted by Jamal Nasir on February 7, 2012 at 3:45 AM Comments comments (1)

Date.new(Time.now.year, 12, 31)

The above line will create a date with the current year, 12 months and 31 days.


This will subtract the current month number of month from 12. For example;

If it is Febuary (2), the above line of code will give you 10.


last_day_of_month= (Date.new(Time.now.year, 12, 31) << (12-Time.now.month)).day

So, the above line will give you the last day of month.

MVC Architecture

Posted by Rq Bukhari on January 24, 2012 at 6:55 AM Comments comments (3)

MVC architecture is a software architecture used in software engineering. Ruby on rails uses MVC (Model, View, Controller) architecture. The MVC architecture of ruby on rails make it easy to keep the code DRY and makes clear where different types of code belongs. This makes the maintenance of code easy.

Read Full Post »

Installing Ruby, Rails and MySQL without RVM on Ubuntu

Posted by Rq Bukhari on January 7, 2012 at 9:30 PM Comments comments (1)


The best way to install Ruby is by using RVM but those who don't want to install RVM; this guide may be helpful for them. Installing Ruby without RVM is also easy process. You can directly install it from the apt Using the command:

Read Full Post »

Installing RVM, Ruby, Rails and MySQL on Ubuntu

Posted by Rq Bukhari on January 7, 2012 at 2:05 PM Comments comments (2)

This guide will help you install and set up ruby 1.9.2, RVM, Rails and MySQL on Ubuntu machine. If you are not using Ubuntu then don't try this method to install rails.


Before starting the installation we will run the sudo...

Read Full Post »

Agile Web Development

Posted by Rq Bukhari on January 7, 2012 at 12:50 AM Comments comments (1)

Feature Planning Workshop


A feature planning workshop is essentially a brainstorming session. At a bare minimum, the group will consist of the developer's team manager and the person leading the project from within your own org...

Read Full Post »