" Live as if you were to die tomorrow. Learn as if you were to live forever.. "
- Mahatma Gandhi

How to work with CSRF token while AJAX posting in Rails 3.1.

Posted on November 23rd, 2015 by DEBADATT PRADHAN

Hi Railities Here is a tip on how to work with CSRF token while ajax posting in rails 3.1. Query:- While we are doing AJAX post , automatically the current session destroys in rails 3, and the current user automatically logged out. Description for the query:- While creating a rails app it creats a CSRF(Cross […]

Upload image in rails3 without using any gem

Posted on November 23rd, 2015 by Bachan Smruty

For image uploading, rails3 having plugins and gems. But here we are going to discuss on how to upload and remove images through rails3 without using gems or plugins. Here I am going to discuss on how to upload image using rails3 application. There are many gems and plugins available for this. But here we […]

Use of Custom ConfigurationVariables

Posted on November 23rd, 2015 by Bachan Smruty

Instead of using hard-coded values in the application, better to keep those in the configuration file and while needed just parse it into an array and use it in your application. Here I am going to discuss how to create a custom configuration file and load it as per the environment(developement, testing, production) in ror(Rails3). […]

Send SMS from fullonsms.com via our Rails Application

Posted on November 23rd, 2015 by AJAY SAHU

By using  this small Trick we can send SMS to any Indian Mobile number from fullonsms via our Rails Application. For this we need  a gem ‘mechanize’  It will help us to render our html pages, forms, form elements etc . So let’s go ahead and install this gem for our Rails application. Add gem […]

Render Prev & Next Record From Show Page in Rails

Posted on November 23rd, 2015 by AJAY SAHU

Scenario: In Rails we can click individual record and open it from index page but to open the next record we need to go back to index & click another link.  But we can have a Prev / Next Navigation options in our show page to render our previous/next records without clicking individual links. We […]

Keep Our Drop Down & Index List Sorted For Better User Experience

Posted on November 23rd, 2015 by AJAY SAHU

Generally when we fetch records from our DB and render those in our view without caring about sorting those records. Let’s consider a case, we have doctors name in a dropdown and patient needs to chose one doctor whose name is “James Brito”.  If we have 1000 doctor names then it’ll be quite tough for […]

Using UJS in will_paginate gem in Rails3

Posted on November 23rd, 2015 by Bachan Smruty

The will_paginate (https://github.com/mislav/will_paginate) gem is a popular gem, that developers usually use for the pagination. It populates the links for the pagination and upon clicking the link, it will load the content. For adding UJS to these paginate links, we need to override the helper methods of the will_paginate gem. In the following, I am […]

Skinny C & Fat M approach in Rails

Posted on November 23rd, 2015 by Ajay Sahu

Basically whe we are novice to rails application, we used to place all our codes in our view pages and used to keep our model & controller files almost blank. For a sample app  our view, controller and model files used to look some way similar to this : #view               Here we […]

Use MySQL DB for your rails Application ( Windows)

Posted on November 23rd, 2015 by Ajay Sahu

Here I am assuming ruby on rails setup + MySQL Database has been installed in your windows machine. We will follow couple of steps and will use MySQL Database for our rails application. Step -1: $ rails new mySQL_Example –database=mysql #by applying –database=mysql parameter, check your Gemfile, it must include gem ‘mysql2’. our procedure seems […]