Things which Rails could do but I didn’t know.

Run Helper methods in the console $rails c => helper.number_to_currency(100) => “$100.00” => helper.time_ago_in_words(3.days.ago) => “3 days” Shorthand Migrations $ rails g resource person first_name:string last_name:string email:string token:string You can write above command as- $ rails g resource person first_name last_name email token Both will generate same migration: class CreatePeople < ActiveRecord::Migration def change create_table…

Avoid rails helper times_ago_in_words()

Let’s say we have 100 records in lessons table then %td.last_modified= times_ago_in_words(lesson.updated_at) server calculate the time ago for each record for each request, it wastes a lot of time on server side. If we replace above code by %td.last_modified”= lesson.updated_at.to_s and load jquery plugin  <script src=”jquery.timeago.js” type=”text/javascript”></script> then in JavaScript $(“td.last_modified”).timeago() thats it. Then the…

jquery ketchup-plugin for Client-side form-validation:

jquery ketchup-plugin for Client-side form-validation: There are many jquery plugins available for client-side form validation (to validate form before actually submitting it). jquery ketchup-plugin is one of them. Github: https://github.com/mustardamus/ketchup-plugin Demo: http://demos.usejquery.com/ketchup-plugin/ Validations provided by plugin: https://github.com/mustardamus/ketchup-plugin/blob/master/jquery.ketchup.validations.js Steps: 1. include css file in your application.css file *= require jquery.ketchup 2. include js file in your…