Featured
-
Installing RVM and Creation of Gemsets Part 2
In the last tutorial we learnt how to install RVM.
by dinesh.singh -
Installing RVM and Creating of Gemsets Part 1
Installing RVM and creating Gemsets can be difficu
by dinesh.singh -
Use pik in Windows
Managing multiple versions of Ruby on Windows can
by anirudh.rautela -
Using Bundler in Rails 2.3.x app
Managing Gems in Rails can be infuriating at times
by anirudh.rautela
Tags
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...
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...
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...
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...
Using rolify devise and cancan gem together for user authorizations and access in rails
Hi friends,
Whenever we create an application, there is always a case where we want to have different kind of users who needs to login into the app but they have different access rights, so that some functionalities are hidden for some users and...
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...
control structure
In programming our program must act according to our control structure, it must follow the rules and conditions which are supposed to be follow, for this we use some conditions that is known as conditional flow, by this our program do what we wan...
validations in ruby
Validation
There must be something twirling inside your mind after seeing validations in ruby, validation
are basically used to check whether you are sending right parameters or not. i will explain you
by brief code
class School <...
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:
&...
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...
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...
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...
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...
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 ...
Using friendly_id gem or slugged id in rails
What friendly gem can do?
Friendly_Id is the "Swiss Army bulldozer" of slugging and permalink plugins for Active Record. It lets you create pretty URLs and work with human-friendly strings as if they were numeric ids.
Ra...
Active Admin Gem rails
Installing Active Admin Gem
gem 'activeadmin'
# Integrations possible with:
gem 'devise'
gem 'cancan' # or cancancan
gem 'draper'
gem 'pundit'
Quick Setup Active Admin
...
how to do ajax call through jquery function in rails 4 ?
This is our ruby on rails view from where called our jquery function().
<td id= <%= "reject_#{event.id}" %>>
<%= button_tag "Accept" , :onclick => "abc('#{event.id}', 'Accept');" %>
...
How to create a new column in an existing table in Rails
This the existing table in migration folder.
class CreateArticles < ActiveRecord::Migration
def change
create_table :articles do |t|
t.string :title
t.text :text
t.timestamps null: false
end
end
end
...
Why Should You Consider Ruby on Rails Programming and Its Framework?
Source: tinhthongsoft.com
Ruby, an Object Oriented scripting language for web-development, gets extension from a software library called Rails. As a collective framework for web developm...
Different ways to invoke method in ruby
Ruby provide with the following ways by which you can invoke the method based on your requirement :
s= "ruby method"
1) Call a public instance method directly
p s.length #=> 11
2) Other way is to invoke a method dynamically in ...
Managing processes using Foreman gem
Foreman is a gem (aka manager) for managing multiple processes that your rails application is depending upon when running in development environment and also has a option to move it into production environment as well. It is based on a Procfile t...
Rails Server Setup with passenger and nginx
Rails Server setup with Passenger and nginx
Hi friends,
Today I am going to tell you how to setup rails server with nginx and passenger. First you need to login to your server using ssh using the command
ssh -i server_pem_key_path user@...
Strong Parameters in Rails
Strong Parameters in Rails
Strong parameters are used to prevent the action controller parameters that are used in Active Model Mass Assignment. If you want to use them, you need to white-list them. It is basically used as a security for sensiti...
default_url_options in Rails
default_url_options in Rails
Rails has a url_for helper, which is used for generating hyperlinks. So many times we want that a certain thing or parameter needs to be passed with each link or request to tell the controller to do certain thing...
Use of Flash in Rails
Use of Flash in Rails
In rails, flash is also used as a session management method. Its feature is that it gets cleared after every request. It is basically used when we just want to show a message in the next request or view and don't want t...
JQuery Ajax Post in Rails with example
JQuery Ajax Post in Rails
As we all know, ajax is used for saving some objects to server or requesting to server and in response, page should not be refreshed. Rails provides helper remote: true, that can be added in ruby form helpers. After a...
Using Cookies in ROR
Cookies are objects that we use to store some information of the user in the browser like geolocation of user . It is a set of key value pair. All cookies have time of expiry after which they are just deleted from the browser usually at the end o...
Rendering XML and JSON in rails
Rendering xml or json data from the controller method is very easy. We have to just follow this syntax.
Example(xml):
def index
@users = User.all
respond_to do |format|
format.xml {render :xml => @users}
...
Adding Translations in Rails
Adding Translation to a Rails Application
Hi friends, in my previous blogs related to internationalization of rails application, we have configured the i18N api and saw different types of methods to pass the locals, if you have not read thos...
Setting Rails Locales from URL
Rails Internationalization : Setting locals from URL
In my previous blog, we looked in Setting rails locale from domain name, it was a good approach of detecting the desired locale from domain or subdomain, but sometimes you are not able to ...
Setting rails locals from Client Requests
Rails Internationalization : Setting locals from Client Requests
Hi friends, in my previous blog, we looked into Setting the Locale from the URL Params. There are some more cases where we don't want to set the locales through URLs or domains...
Setting rails locale from domain name in rails for internationalization
Rails Internationalization : Setting locale from Domain Name
For translating your application to other language, you can set I18n.default_locale to your locale in application.rb or in initializers as I told in my previous blog Configuring i1...
Before and After Filters in Rails
Filter in Rails
Filters are the methods, that run before, after or around a controller action. We can better understand it by taking an example. Suppose in a blogging site, there are groups and we want that a user can only read blogs of his gr...
Rails: Using forms for operations like Patch, Put , Delete
Hi friends,
As we all know, rails always encourages RESTful (REpresentational State Transfer) design for resources, that specifies standards for using different kind of requests. Rails also supports this. Thus if you are using RESTful, you would...
Date and Time Helpers in Rails
Date and Time Helpers in Rails
Date and time selection are very common in forms for saving event times, schedules, birth date etc. Rails also provides date and time helpers for taking inputs of date, time or datetime. While dealing with date...
Uploading Files in Rails
Uploading Files in Rails
Uploading files from a form is a very common task(i.e uploading images, files etc). As you may already know that you need to set multipart/form-data, if you want to upload files from a form. Similarly in rails, you need ...
Creating Select Boxes using form helpers in rails
One of the most common html elements in a web page is select box. In Rails select and option tag helper method is used to display it .
select and option tag:
<%= select_tag(:city_id, options_for_select[[Bangalore, 1], [Dehradun, 2]]) %&g...
Rails:Populating Select boxes with model data
In model specific form we use select method to display a select box and populate it with model data.
Example:
#controller
@location = Location.new()
#view
<%= select(:location,:city_id,City.all.collect {|p| [ p.name, p.id ] }) %&g...
Creating Basic Search Form in Rails
Hi Friends,
As we know that, currently there are plenty of content based sites and we usually see a search box within that, to search any topic that is available in that site. So today we will be discussing on how to create a basic search form i...
Form Helpers in Rails Part-4 (Building Complex Forms)
Hi friends,
In my previous blog, we talked about customization of form helpers and how to create forms for external resources through form helpers in Form Helpers in Rails Part-3. Now we will switch to discuss on how to build complex forms in ra...
using head to create header response
While sending an ajax request in rails sometimes we dont need to render any data back to the page . Only status 200 is sufficient to show changes in the view page then we use render :nothing option but there is an alternative to it is head metho...
Form Helpers in Rails Part-3 (Customization and Forms for External Resources)
Hi friends,
Previously we talked about form helpers dealing with models in Form Helpers in Rails Part-2. Today we will continue with Form Builders Customizations.
As we already discussed that objects from form_for and fields_for are instance of...
Use of Render option in Ruby on Rails
render() method in rails is used for rendering a content to the view . Its uses are:
In Controller for rendering an action
Example:
render :action => "show"
This is the most common use of render in controller . The template for sh...
Form Helpers in Rails Part-2 (Model Objects)
Hi Friends,
In my previous blog Form Helpers in Rails Part-1, we have talked about only the basic form helpers. Today we will be discussing forms with models. As we know in MVC, forms are mostly used for creating, updating or editing models. So...
Form Helpers in Rails Part 1 (Basics)
Hi Friends,
In my previous blogs, I have talked about so many topics related to Ruby on Rails. Now today I am going to start form helpers in rails. As all the points can't be covered in one blog, I am dividing it into parts. Today I will be deal...