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

Solution to the problem when scaffold inherits the inherited class due to active admin

Solution to the problem when scaffold inherits the inherited class and not the application controller due to active admin   While creating a web application in rails we always need an admin panel through which we can manage t...

Rails Active Records Callbacks: Part 2

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

Array Conditions and selecting specific fields to find or retrieve from database (Active records)

Array Conditions and selecting specific fields to find or retrieve from database through Active records Array Conditions To retrieve some specific data from the database we use the where method which gets the records in the form o...

Rails Active Records Callbacks: Part 1

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

How to get mailchimp-api-key

API stands for application programming interface and used to communicate between two different applications. In order to integration of “mailchimp-api” rails app, we'll need to Mailchimp_Api_Key. We can get this  parameter...

Customizing Routes with resources

Hi Friends, In my previous blog Routes in Rails using Objects, I explained about using routes with objects. Today I am going to tell you about how we can customize the routes that are created using resources. As we know whenever we mention res...

Adding, Removing or Changing a column through Active Records in Rails

While creating a web application we create models in our application which act as tables in the database. Sometimes when the development of the application moves further, the need arises to add a column to our existing table or removing a column ...

Routes in Rails using Objects

Hi friends, Whenever a request comes to a server, the first thing comes into picture is routes, that tells the request about which controller's action will respond to that request. When I started creating my first application one thing alw...

Find out days count in a year

Description: A variation of determining leap years, assuming only integers are used and years can be negative and positive. Write a function which will return the days in the year and the year entered in a string. For example, 2000, entered...

Add Subscriber to a MailChimp using mailchimp-api gem or mailchimp-api Integration in application

Lets supposed we have requirement to add a subscriber to mailchimp while user registering on our website. For this, we can use 'mailchimp-api' gem & we can integrate mailchimp-api gem as following in our application add gem in Gemf...

Listing, Managing and Using Ruby versions

Listing, Managing and Using Ruby versions in Rails application I am writing this blog to discuss how can we see ruby versions installed in our system. In addition to it this blog also contains how can we manage them and use different v...

Compare similar words in two strings

DESCRIPTION: Two Samurai Generals are discussing dinner plans after a battle, but they don’t appear to reach a consensus.   The discussion gets heated and you cannot risk favoring either of them as this might damage your political...

Count the occurence of an interger in a string

Description: Given a string of integers, count how many times that integer repeats itself, then return a string showing the count and the integer. Example: countMe('1123') (count_me in Ruby) Here 1 comes twice so <count>...

Use of Migration in Rails

Rails Migrations can be used to alter the database.Migration allows ruby to define the changes in database schema in a consistent and easy way. So If one deleloper make some changes in database schema, the other developers just need to update, a...

Handling Invalid JSON errors in rails

Handling Invalid JSON Error in Rails  Hi Friends, Sometimes by mistake, when we send an incorrect JSON to server, the server is not able of handle the improper JSON so it throws an error, and the client doesn't get any proper error m...

Ruby on Rails Command Line: Part 2

Hi Friends, In my previous blog Rails Command Line Tools. I discussed about some rails command line tools. Today I am going to tell you about rake command in rails. rake is actually a ruby version of unix's make command. It is also used to...

Rails scaffolding

Rails scaffold can create the models, views, and controllers for a new resource in a single operation. Scaffold Would create a full CRUD (create, read, update, delete) for a table. Scaffold auto generate all the codes that rails needs. Later we...

Create a Custom Rake Task

Rake is a Ruby task management tool. Like in Unix we have 'make' utility. So we can say Rake is Ruby Make. It uses a Rakefile and .rake files to create a list of tasks. We can see all the Rake tasks available in our current directory by...

Rails Command Line Tools

Rails is a language particularly known for its rapid development and shortcut commands that make development of applications and its modules fast and easy. Today I am going to tell you about few most basic commands of rails: 1. rails new: ...

Adding social icons in your site

Hi friends, You might have seen several icons of social networks in many of the sites. If you want to add this in  your rails site, there is already a beautiful gem called social-share-button. I am explaining here how you can integrate it s...

Rails custom ordering of record

Sometimes we need to display the records in a specific order. For that, we need some method Suppose I have the priorities ['0', '8', '4'] .And I have a model event with priority column. Now I need to get all the even...

Publishing ICalendar with Ruby on Rails

If your application has certain events(For example meeting etc), then you may need to integrate calendar application. Icalendar is a standard for calendar data exchange. Icalendar allows us to generate .ics files so that users can add events to...

Difference between scope and namespace in Rails

As we know,Both scope and namespace have to do something with the config/routes.rb file  .Yes,in some way ,both are wrapper for our well-known resources method. First,understand the working of scope by examining how it generates paths.Consid...

Braintree integration with Ruby on Rails

While working on an e-commerce project we need a secure payment system and Braintree framework is one of them. With Braintree, we can perform all types of credit card transactions and PayPal transactions. The first step is to crate account in s...

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

variables in ruby

Variables in ruby Variables are used to hold any data which will be later used by programs. There are 5 types of variables in ruby 1.Ruby global variables 2.Ruby instance variables 3.Ruby class varibles 4.Ruby local variable 5.Ruby...

Rails select_tag helper method

Going by my application, I have an index.html.erb file that lists all articles and i was in need of a search box that would search all articles depending on the selected category.So firstly ,I created a search box within index.html.erb like this ...

Model Unit-Test case for validations and associations using "test-unit" gem in rails 4

In order to write a unit test case for model in rails 4, Let's suppose that we have a model city.rb which has some validations and associations. #Rails 4.1.14.2 & ruby-2.1.7 Model path: my_app/app/models/city.rb, like... class ...

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

Adding a default value for a column through migration

Consider the following scenario. Let us say we have a User model and users ,its corresponding table in the database has a column role_id along with other columns. During the time of the attachment of the role_id to users table ,we could hav...

Rail Forms

 form_for <%= form_for(@article) do |f| %> <%= f.label :title %> <%= f.text_field :title %> <%end%> In this example i supplied an object of article to the form_for method. It will generate the f...

implement thumbnail image in image uploader

how to implement thumbnail for image in rails. step 1:- go to uploader inside views where you have written image uploader code for uploading image. uncomment this section #Create different versions of your uploaded files: ve...

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

views in ruby

Hello friends, I hope you all are doing well, so today I would be discussing rails view in ruby in rails. View in ruby is used to display the data which is requested by controller from web with the help of shareable variables. We usually end view...

Rails Sql Queries

find method: The find method is used to find the particular object that matches with the parameter supplied to it. article = Article.find(11) #It is used to find the article whose primary key is 11. # => #<Article id: 11, name: ...

How to customize the redirect after a successful account updation using devise

Here we want to render a custom page like the user's profile page after a successful account updation.The solution is fairly simple,however one  prerequisite i am assuming that we have already run rails generate devise:controller user co...

Important Methods of Date in Ruby

We often stuck, how to manipulate Date in our rails Application.   We have two Date objects in Ruby Time.now() // This will give Today's date #=> 2016-05-17 17:02:28 +0530 Date.new() // This will need some arguments to pa...

before_filter TestCase for ApplicationController using "Unit Test" approach or "test-unit" gem

I am using Browsernizer gem to prevent some browsers version from accessing website and redirect to a static instruction page to upgrade browser version. So using before_filter method in ApplicationController to detect browser version & re...

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

Ruby Constructors and Setter and Getter

Ruby Constructors  1. Ruby supports constructors.  2. They are declared with the method initialize.  3. Initialize method is called automatically when the object is created. Example: class Cons def initiali...

routes and resources in ruby

If you are new to ruby then you must have wondered about what is routes in ruby, so today I will discuss everything about routes in detail. Rail routes are used to dispatch URl to the controllers action. it is used to generate path for particular...

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

$this vs $scope in AngularJs

$scope and $this are the mostly used in AngularJs. But we often caught up in a perplexed situation, which one we should use. whatever we define in a certain block(or DIV) of HTML, all the variables comes under the $scope or this. for exa...

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 ...
1 2 4 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: