Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

Conversion of binary value to an integer

Description: Given an array of one's and zero's convert the equivalent binary value to an integer. Eg: [0, 0, 0, 1] is treated as 0001 which is the binary representation of 1 Examples: Testing: [0, 0, 0, 1] ==> 1 Testing...

find_all method in ruby.

The find_all method has to do with arrays in Ruby.This method simply iterates through all the elements in an array and meanwhile test each of them against a test condition and finally returns an array containing all elements for which the test re...

Page caching in Rails

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 Paypal in Rails Application (Part-2)

Paypal Integration in Rails (continued) Now, When the user is redirected to the method paypal_url , defined in the model file (order.rb) there we will give the html variables in which we will connect our application to the pa...

Integrating Paypal In Rails Application (Part-1)

Paypal Integration in Rails As we know that these days many web applications have the functionality and requirements of money transactions. For example today we will take an example, of an e-commerce website or we can say an online shopping we...

Some useful built-in Functions in Ruby

1) at_exit { code to be executed} This method starts the execution of the code when the program exits. For Example: puts "Begining of execution" at_exit do puts "Inside at_exit" end puts "End of execution" Output: Begining of...

Singleton methods in rails

A regular instance method can be used by all the instances of that class and all of them will inherit their behavior from its class. But what if we want a particular instance to have a specific behavior that no other instance can have that is whe...

Cloning and freezing objects

Suppose we have an object and that object is assigned to two different variables. Now if we make any changes to one variable the other variable's will automatically change. For example Obj_1 = [1,2,3] obj_2 = obj_1 obj_2 << 4...

puts vs p in rails

While writing the code, we often need to print a particular object and see the result. In rails we use puts and p for that. Both will display the result but there is a difference between them.puts prints the result by applying to_s on an object ...

How override layout in controller in rails?

Lets suppose we a have requirement to customize our layout for different controllers, means different controller will have different layout and basically we want to change the style of different controllers views. To override a layout on the basi...

Pagination in rails using 'will_paginate' gem

Lets suppose we have articles listing page and we need to show the 10 article per page. So there are we can use 'will_paginate' gem to divide the articles in number of pages. There are the following steps to integrate the 'will_pag...

Integrate bootstrap-sass in Rails

Bootstrap is an open-source web design framework from Twitter. Bootstrap framework makes it easy for a developer to create a layout for an application. There are predefined CSS classes for creating common components such as widgets, elements, li...

Create rake task to import csv file in rails

Lets suppose that a file named product.csv exists into db folder in our applications. To import this file we will create file import.rake in my_app/lib/tasks/. The import.rake file looks like... require 'csv' desc "Import product from cs...

Import products from a CSV file in rails

Lets suppose we want to import a products CSV file in rails i.e. reading rows from CSV file and inserting its into a table. There are the following steps which we will use to import CSV file. Create an application using command rails new ...

Analytics for Ruby

To integrate analytics into Rails application analytics-ruby gem can be used. By using this gem we can identify users and track their activity. To install into gemfile: gem 'analytics-ruby', :require => "segment"   After tha...

Money-Rails

While working on any e-commerce application,we need to deal with money and currency conversion.Money-Rails gem can be used for that. Money-Rails is a Ruby Library that integrates money gem with Rails.   Some of the advantages of using ...

Acts As Votable

Acts As Votable is a Ruby Gem. It is used to give user a way to Like and unlike something(Post, Link etc) and update the counter each time they click without refreshing the page. This gem is specically written for Rails/ActiveRecord models, and ...

Integrating Backbone JS with Rails Application

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

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 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

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 ...

Ruby Length vs Size vs Count method

Ruby provides us three methods to interact with Array, Hashes or Objects.   Length Size Count   Lets takes a simple array to explain the difference between these methods   array1 = [A, B, C, D, E] &nbs...

Ranges in Ruby

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

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

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

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...

Error- 443: Network is unreachable while installing RVM

If you are setting up RoR on a system, and while installing RVM you get an error like curl: (7) Failed to connect to get.rvm.io port 443: Network is unreachable this is due to mis-configured ipv4 & ipv6.   As you already kn...

Dealing with Files in Ruby

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

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...

Dealing with Directories in Ruby

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 ...

How to install and use Active Admin as your Admin Panel for Rails Application?

As we know that these days every web application needs an admin panel which allows the owner or the manager of the web application to manage all the data and restrict the accessibility of certain things to certain users. For that there is a ge...

Importing and Exporting Records in CSV format in Rails

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

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...

Kaminari Gem

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...

Some Server Side Validations in Rails (Active Records)

Hello Everyone, As we know that in almost all web applications there are certain things which need validations to be performed on them. Validations can be performed in two ways that is client side and server side. Client side validations...

How to install Rails admin in Rails application

How to install Rails admin in Rails application As we know that almost all web applications have an admin panel through which the administrator of the application  can manage all the data of the application and make necessary chan...

Redirect Back To Same URL after Login through Devise in Rails

In almost every web application there are certain things which a user is allowed to do only after he or she is logged  in into the website. If user  trying to access some page or some URL where he/she can get access only after logging i...

Integrating Comparable charts in Rails Application

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 ...

Kaminari gem implementation in Rails

Kaminari is a very popular pagination gem for Rials . It's a Scope & Engine based, clean, powerful, customizable and sophisticated paginator gem which uses scopes to flow nicely with Active Record queries. Features of Kaminari: &nb...

Bitmask Attributes in Rails

Sometimes we need to store several booleans to determine a user's settings.Bitmask is a good solution for that.Bitmask use a single integer where each bit represents one such boolean. For example user has many roles.One solution would be cre...

Calculations in Active Records Query Interface

Active records query interface provide us with some very nice features to perform calculations or mathematical operations to retrieve selected records on the basis of those mathematical calculations. Those methods are as follows: Count ...

Rails Active Record Callbacks: Part 3: [after_find after_initialize and conditional]

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...

Some useful git command

When a group of people is working on the same project then it's mandatory to have any version control system, so that everyone can work without having any conflict. Git is one of the popular distributed version control systems that we have. ...

Rails MailChimp API

We use MailChimp for sending emails, specially when we have to send an email to a bunch of people at once. Using MailChimp we can add new users to our mailing list, we can send a welcome email to the new user and can send a notification to users ...

Hash Conditions in Active Records (Rails)

Hash Conditions in Active Records (Rails) Active records allows us to to pass in array conditions to our query to fetch a single record or all the records matching  the key value pair. In these hash conditions we pass the key as the na...

Browsernizer gem integration

We can use browsernizer gem to restrict an application to open on old version of browsers or we can notify user to upgrade browser. Add gem to Gemfile gem 'browsernizer' Run bundel install rails generate browsernizer:install ...

Some Common Validation in Active Records (Rails)

Hello everyone, As we know in almost all the web applications there are forms, text boxes and several other fields which need big time validations so that the security of the application is maintained and no one should be able to alter it or p...

Meta-Tags in Ruby on Rails

Meta tags are used for search engine optimization.Using meta tags we can control how are website should look on social sites when it is shared. There are two important meta tags: Meta description tags Meta keyword tags Some search engines d...

Integrating ckeditor in Rails

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 ...

Simple Search Functionality In Rails

Integrating Simple Search Functionality In Rails As we know that in almost all the web applications there is a search functionality. This functionality includes a search bar or search text box in which we can write the thing which we want to s...
1 3 10
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: