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

Sharing Feature With Social Media in Rails App

Sharing Feature With Social Media in Rails App As we know these days almost all web applications provide us with the option to share anything on any social, media website so that our friends or other users on those social medias could watch...

JQuery Slider For Rails

JQuery Slider For Rails As we know these days in almost all applications there are image sliders which keep rotating and displaying images one by one like a slide show. To integrate the same functionality there is a gem which we can use to ...

Pagination in Rails Using will_paginate Gem

Hi Friends, Today I am going to tell you how we can integrate pagination in rails. First let's know why pagination is required in an application. Pagination is fetching data in batches and rendering one batch  at a time. It is nece...

Finding or Building a New Object In Rails Through Active Records

Finding or Building a New Object In Rails Through Active Records Active records provide us with some methods which we can use in our database to find or create objects automatically without having to fire two queries. These methods run 2...

Ordering, Limit and Offset in Active Records Rails

Active records provide us with ways to set constraints in our queries to specify the order in which we have to get the records from the table. This can be done through the following ways:  order This method is used to get recor...

Retrieving a Single Object From Active Records In Rails

Active records gives us different ways to retrieve single objects from it. Those methods with examples are given below :  find The find method allows us to retrieve a single object or we can say single record from the database ...

Rspec PART 1 - Introduction

Introduction to Testing: The question that always arises is that why we should test a software/code? can't developers code  like we need not to write test cases for it to ensure its correctness and quality. The answer to above ques...

Use of seeds in Rails

Hi Friends, Few days back I was facing an issue that once I was creating an application in development mode, I needed to sign up to my application with fake emails, so that was very troublesome process, so I found out about seeds in rails. ...

Active Record Migrations In Rails

Migrations in Rails Active records provide us with a very useful feature to change or alter our database schema in ruby on rails. Through these migrations we can make necessary changes to our database and make changes in our tables and rows...

Service Objects in Rails (Refactoring)

"Fat models, skinny controllers" has been the design style for Rails app development. However, with time this style has been outdated as with code growth the models become too fat to handle. Why not use concerns? ActiveSupport c...

CRUD operations in Rails

CRUD Operations in Rails Before understanding CRUD operations in rails we will see what are active records. Active records point to the models of MVC architecture. Model is the component of mvc architecture which is responsible for persisting ...

Iterators in Ruby

Iterators are used to iterate over each element of a collection or array one by one. In ruby there are different types of iterators. Here we are going to discuss over each and collect. 1. each: It iterates over each element of the array or ...

None and readonly methods in active records rails

Hi friends, There are some special kinds of methods in active records rails, that can be used for different purposes. Here I am explaining two of them 1. none method: none method as its name suggests returns no records. So it is used in ...

yield in ruby

Hello friends, Today while programming in ruby and I came to know about the yield word in ruby, how important this word is in ruby, I will discuss some example where to use yield in ruby. As while programming in ruby you must have used blocks ...

Implementing file upload functionality with PapaerClip Gem

Uploading a file in rails through Paperclip As we know these days almost all the applications have the requirement to upload files to the application then be it an image , a video or any other file. I am writing this blog to share with you all...

Using Braintree As Payment Gateway (Part 1)

There are several player in the market which can be used as payment gateway and it is not always easy to choose one . Thus today I would like to give you an overview of well known payment gateway i.e Braintree which is a subsidiary of Paypal. The...

Collections in Ruby

Whenever we code in any language, the first question arises that, what are the important Data collection in the corresponding Language contains. As we have Ruby language with us. We have some nice Data Collections here. Array Hash Se...

Draper decorator (rails refactoring)

In this tutorial we will have a look on Draper gem, which helps us decorate our views more like in object oriented approach. Its a great gem and provides us lots of options to decorate single object and collection of objects. We discussed present...

Devise gem in Ruby on rails

Devise gem is one of the highly recommended gem used in Ruby on Rails. It has many features such as Email sending, locking User, Authenticating user and many more.   To install Devise gem, you need to specify it in your Gemfile g...

Form objects with Reform gem (Rails refactoring)

We have been discussing refactoring in our previous posts. Next to our refactoring pattern, we will discuss few gems that can be used to improve our coding style.   In my last post i explained form objects pattern. Form objects are not...

Special Finders in Ruby on Rails

Rails has different types of finder methods that reduces your great amount of time. Suppose you want to create a record only if it doesn't exist already, your first approach would be first find the record and if is not already exist then you ...

Form objects pattern (refactoring)

In previous tutorial we discussed refactoring code and decorators pattern. In this tutorial we will take our discussion further to form objects pattern. We use forms in our application to take inputs from user. The form data is received in our co...

Difference between reset and drop in rails

We often use rake db:reset command for recreating the database, instead of conventional 3-steps for doing the same. rake db:drop (dropping the Database, wipe away all your data) rake db:create (Create the Database) rake db:migrate (Runs...

Model View Controller Architecture (MVC)

MVC Architecture MVC architecture is a software constructing or designing pattern which is widely used these days to build software applications or web based applications. MVC breaks an application into three main parts namely Model ,View a...

Reading content from file and saving it to database in Rails

Hi friends,   Sometimes we want to read the content from a file and save into our database. So we can achieve this in rails we do following:    1) First you need to add a column in your model where you want to save the content ...

Select Vs Pluck in Rails

In this tutorial we will see how we can use pluck and select in rails active record queries.   Select is used to fetch records with specific attributes. It returns ActiveRecord::Relation object.   Project.select(:id) Project...

Enumerators in Ruby

Enumerable Methods in Ruby Ruby has a list of enumerable methods or we can say enumerators that have specific functionalities which can be applied on various collections like array ,hashes etc Map Select Each Collect Map ...

Image upload using carrierwave in rails

Hi friends, Today I am going to tell you how we can upload images in rails using carrierwave gem. It automatically creates folder inside public folder and uploads images there. You can also customize the upload location. Here is the step-by-st...

Integrating Recaptcha in Rails with Devise

Hi friends, Few days back I was facing difficulty in integrating recaptcha with rails so once after integrated it and I though it would be helpful for you guyz, if I mention it step-by-step as I did. 1. Open your Gemfile and add this code: &...

Access Controls with examples in Ruby

Access controls refers to the methods which allow you to set the access to classes, methods and other members. They are used to encapsulate the components so that we can maintain security of these methods throughout the project. Ruby gives us ...

Rescue Exception

An exception is an instance of the class Exception or a descendant. In ruby to rescue exceptions we do something like this:   def process_request! #some code here rescue Rails.logger.error { "#{e.message} #{e.backtrace.join(...

array and hashes in ruby

Ruby array is a list of elements that can be of any type either string or integer. Hence, In ruby it can be integer or string.  we can declare array by placing the elements inside the brackets like;- arr = [1,"array",2,3,"h...

Sending SMS using Twilio: Rails

Send SMS using Twilio: Rails Twilio is a SMS gateway service that lets you send and receive SMS using your application. For testing purpose, it allows you to send SMS for free to few numbers. To start integrating twilio, you fir...

Refactoring Code in Rails

While developing some functionality, sometimes we take shortcuts to finish it on scheduled delivery time. We give less time on code standards and more on functionality. But with code growth we have perfect opportunity to clean our code and follow...

Exception Notifications via email in Rails

Sending Notifications on Exceptions in Rails   Hi Friends, Let's first discuss about debugging a code. During development, suppose you have pushed some changes, then you need to test each and every functionality to check whether y...

Sending Emails in Rails using Gmail

Sending Emails in Rails using Gmail Account For sending emails in rails,ActionMailer Class is used. Emails can be sent using any service providers like Gmail, Sendgrid, Mandrill or any other. Here we will see how we can send the emails us...

Blocks in Ruby

A block is a chunk of code that we put inside do..end or {}. You can use any of the both ways. But multiline block (do..end) is preferred over inline({}) block.   Example of block: multiline style# ["red", "green", "yellow"].ea...

Array and operations on array

Array is used to keep collection of objects. Array in ruby can have any type of objects together. Using array in ruby: >> a = [] >> arr = [1, 0, 7] >> arr[2] # => 7 >> arr.size # => 3 >> arr = ["stri...

Using super in ruby

With inheritance in ruby we can share parent class behavior to child classes. We can also override these methods in child classes.   A built-in function called super is provided by Ruby. This method allows us to call methods up the inheri...

Inheritance in Ruby

One of the fundamental aspects of Object-oriented programming is inheritance. Inheritance lets a class inherit properties from another class. Child class acquires behaviours from its parent class. This means the child classes will automatically h...

Export Into Excel in Rails

Export Data into Excel in Rails Hi friends, In my previous blog Import From Excel in Rails. I showed you how can we read excel records from excel sheet and store it into DB in rails. In this we will see how we can download the list in excel for...

Importing From Excel Files in Rails

Importing excel files in Rails Hi friends, Importing excel sheets and storing them into db is a very common usecase of applications. So here I am going to guide you to a step-by-step process of how to import records into db from an excel fi...

Modules

One of the most powerful feature in ruby is module. Modules are like classes but can not instantiated. Module is used for two purpose:   1. namespacing 2. mixin   Namespacing A class per can be wrapped inside a module to...

Rails: Time ago in Words and its Customization

Rails: Customizing Time Ago in Words Hi friends, Whenever something is published to a site, we see in their posted time, it is written like about 2 minutes ago or about an hour ago. These kind of sentences displays how much time before the cont...

Rails Scopes

Rails: Scopes Rails is made for building applications rapidly. Scope is an another example that truly admires this feature. Its use can be explained by taking an example. Suppose you have a blogging site and you want to show everywhere only thos...

Ruby: Dynamic method call using send method

Ruby: Dynamic method call using send method Hi friends, As everybody says rails is a dynamic language. They says this because of its functionalities that makes it dynamic. One of the feature of rails is it's send method. It is an instan...

Ruby: Metaprogramming: Method that makes methods

Ruby: Meta Programming: Method that makes Methods Hi friends, The normal way of defining method is to give the method name after def and write code between def .... end, and it is pretty fine for most of the cases, but sometimes suppose we ...

Create your own Ruby Gem

Hi friends, The popularity of Ruby on Rails now a days is so much because of its rapid development, which is possible because of its gems. For every generic functionality there is a gem available, so why not create our own gem. Today I am going ...

Rails Environment Configuration Variables

While developing Rails application we need to keep our project specific sensitive information secure. For example api keys for third parties like stripe, paypal or passwords or configuration data such as the URL. We can set these as environment...

Block, Proc and Lambda

Blocks, Procs, and Lambdas Hi friends, Today I am going to explain one of the most confusing part in Ruby, that is Block, Procs and Lambdas. It always troubles you during interviews or any other places wherever you deal with Ruby. But actua...
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: