Creating Charts and Graphs in Rails
Few days back I was working on a project, in which a dashboard was needed with stats showing in different kinds of charts. i.e: pie chart, barchart etc. So I looked for a gem that can include all o...

Hi friends,
In my last blog Migrations in Rails: PART 1 - Introduction and Creating Tables I told you what is migration and how we can create tables in migration today I will tell you some other generic queries that are used:
1. Dropp...

render is used to provide response of a request in rails. There are multiple kinds of responses that you can send with request. Lets see one by one:
1) actions:
By default if nothing is specified as render, actions are rendered withing in...

The first concern for every application is its security, so rails by default provides a method protect_from_forgery, which is always present by default in your application, whenever you create a new application. i.e.
class ApplicationControl...

As we all know in SQL transaction are used to maintain the integrity of the data, so that if there are multiple queries written, which has a condition that either all of them are executed or none. So for achieving those rails has written the wrap...

With API becoming so popular these days thanks to SPA base applications, it was also required to keep these APIs secure. So the most popular of securing api's is token based authentication, whose flow is little bit like this:
1. In the b...

From Rails 3.2 to 4.0, there were so many things that got changed. So here I am telling you the major changes that affected the active records, and that you should take care of during updation from 3.2 to 4.0:
1) There were some inconsistenc...

Hi Friends,
Most of the large applications use SOAP for data transfer between two parties. So in rails we can also integrate SOAP support. For this there are multiple gems available. One of the mostly used gem is "savon". So here we ...

In my previous blog Integrating SAML with Rails Application, I told you how we can integrate SAML in your application and also told you few things regarding the Service Provider and Identity Provider. So once you have a ready Identity Provider, e...

SAML is Security Assertion Mark Up Language, which was built to provide authorization between multiple identities, so that multiple services can use the same authentication.
The SAML authentication can basically happen in two ways:
A) SP In...

Hi Friends,
Whenever you create an application it is never for lifetime, there is always something and better comes in the market, and once we talk about rails application, it comes pretty quickly. After every few months rails comes with a new...

Hi Friends,
There were so many changes came with introduction of Rails. So one the major change was regarding the HTTP Patch Requests. From rails 4, whenever a resource is declared in the routes, by default it uses PATCH as primary verb...

Hi Friends,
Git is the great tool for project versioning and code management, but mostly we are unaware so many things. So here I am going to tell you what is stashing in Git.
Sometimes we are working on some code and we don't want it t...

In my previous blog Upgrading Rails from 3.0 to 3.1, I explained you how we can upgrade a rails application from 3.0 to 3.1. In this I am going to show you, what changes are required to update an application from 3.1 to the latest of 3.2 rails ve...

Upgrading a rails application directly from a lower version to a much higher version is never a good idea, so the best idea is to do it step by step. like one upgradation at a time. In my previous blog Things to Notice Before Upgrading Rails Ap...

Ruby provides a number of enumerable methods that we can pass on collections or array for performing searching, sorting etc operations.
Here I will be discussing with all, any, none and find methods:
a) all?
In this every member of the...

1) ==
It is a simple equality operator, that only checks if the value of the left operand is equal to the right operand or not, so returns true or false respectively
<pre>
> x = 5
> y = 5
> x == y
=> true
> y =...

Few days back, I was working on a project where I have to create nested comments on a articles and on showing the article I was needed to show all the nested comments in its hierarchy.So I used closure_tree gem to achieve that. So lets see how I ...

Include: If your application has many classes that need the same code, then we can keep that reusable code in a module and include that module in class.
When we Include a module into a class, it is like we are taking all the methods within the m...

Rails 4 has many new features, and Strong parameter is one of them. Strong parameter allows us to choose attributes that can be whitelisted for mass assignment. In rails 3 we were doing this by listing accessible attributes in the model. But in r...

We often need to integrate search functionality in our application, If our rails application is using PostgreSQL as a database, then we can use pg_search gem. This is the easiest way to add a search feature on any rails application having postgre...

Hi Friends,
As we all know rails works on MVC Architecture, where the controllers acts as the receiver of the requests and sends the response back to the requester. There are actually 3 ways a controller can send a response :
a) render: It ...

Sometimes it happens that our application doesn't support a browser with an older version, in that case, we wish to restrict a user from running our application on an older version. In rails, we have a solution to for this problem.
Browserni...

In modern world, most of the web applications are api based. So using api's we also need to validate the authenticity of the user. When it is a proper web application the authentication of the user is maintained using cookies and sessions. Bu...

In rails, sometimes we don't notice it but there is difference when you use puts to print an object and when you use just p to print an object. One thing let me clear for you, p is not a short form of puts, they both are different.&...

Blocks are basically a group of code that can be stored in a parameter and can be executed. There are majorly two ways of doing this:
1) Implicit:
In implicit, it is a nameless block and it is not passed as a parameter, it is exec...

Overriding Equality of objects
In ruby the equality of the objects depend upon several things, which are
a) ==
b) hash
c) eql?
In normal cases whenever you run == method for string numbers etc it works perfectly fine, but if there ar...

Hash:
Hashes are way of storing data in key-value pair format. Key can be any ruby object ( i.e. string, numbers ). Here we will see some of mostly used methods for hashes.
1) Creating/Initializing a hash:
Hash can be created i...

In our regular programming life, we always come in to situation where we need to pick few elements from array, remove them or insert some elements into them. In ruby there are methods available for such operations. Some of them are:
1) Select:...

Page caching is a technique in which the output of an action is stored as a HTML file and when a request comes for that action,the web server can serve it without going through Action Pack. So basically in this approach we cache the content...

Integrating Backbone JS with Rails Application
It is an era of Single Page Applications. So there are multiple javascripts framework available that supports SPA. Two most popular frameworks are:
Backbone JS
Angular JS
In this section we w...

Sessions, Cookies and Flash in Rails
In rails if we want to store data for multiple request there are majorly three kinds of mechanism can be used for different different purposes.
Flash:
Flash stores the data only until the new re...

Exception Handling in Rails using begin rescue
Exception is a condition, that occurs when something goes wrong in a code. Normally in that case the program gets terminated. In rails, an object containing the information of the error is an inst...

Rails Testing with Cucumber
Hi Friends,
In my previous blog Testing In Rails: Introduction and Creating Test Data, I had given you a brief idea about testing and later we talked about how we can test rails models and controllers. Here ...

In modern programming world, ruby is so much popular because of its easability and general purpose syntaxes. Ranges are yet another example of that feature. They store the start and end of a sequence and rest are assumed to be inside them. Ranges...

Testing In Rails: Functional Testing For Controllers
Hi Guys,
In my previous two blogs Testing In Rails: Introduction and Creating Test Data and Testing In Rails: Unit Testing In Models, I talked about the introduction and usage of ...

Testing In Rails: Unit Testing In Models
Hi friends,
In my previous blog, Testing In Rails: Introduction and Creating Test Data, I had given you a brief introduction of rails test cases and why they are required. Also I guided you how we can ...

Testing In Rails: Introduction and Creating Test Data
Hi friends,
Even if you write code considering every case in mind there is always a chance that your code contains bugs. So the best way of writing a code that contains least num...

In my previous blog Dealing with Directories in Ruby, I explained you, how we can play with directories in ruby. Today I am going to tell you how we can interact with files by opening them in different modes and performing read/write operations i...

Fake S3 Server For Local Development in Rails
Hi Friends,
Once I was developing an application that includes accessing and saving the data to S3 buckets. But I didn't have any S3 account at that time, So I searched for a thing that can si...

Ruby is a rich technology and its integration with system commands makes it much more richer. In Ruby if you want to create, read, delete or change the directory, there is Dir class available for that, which provides multiple methods for dealing ...

CSV files are comma separated values file that stores the data values in tabular format, where each column values are separated by commas. They are the lightest way of storing data in tabular format that is why most of the bulk data are exported ...

Creating PDF from HTML in rails
Hi friends,
In rails if you want to generate a pdf, there are multiple gems available that will make your task easy. Normally the approach for creating a pdf will be first create a html template and then conver...

Hi Friends,
Pagination helps us distributing a large amount of data in batches and show them in the views. In rails there are so many gems available for pagination like will paginate, kaminari. Today I am going to tell you how we can integrate K...

The best way of representing a data set for analysis is using charts. So if you are developing a rails application and you want to show the analytics as charts in the dashboard, there are multiple gems available in the rubygems community. Here I ...

Hi friends,
In my previous two blogs Rails Active Records Callbacks: Part 1 and Rails Active Records Callbacks: Part 2, I explained about available rails active records callbacks available. Now I will talk about some more callbacks method...

Hi friends,
Today I am going to talk about how to integrate ckeditor (a text editor) in your rails application. Ckeditor is the most commonly used text editor now a days, because of that there are so many gems available. Here I am ...

Hi Friends,
In my previous blog Rails Active Records Callbacks: Part 1, I explained about why these callbacks are required and also discussed about some of the useful methods available in rails active records during creation and saving of the ...

Hi friends,
Whenever you create,save or initialize an object there are so many things available in rails that are called Callbacks or Hooks. They can be used as checks between on stage of the object to another. In this chapter I am going to ex...