Model Relationship in “rails-backbone”

Introduction Backbone-associations provides a way of specifying one to one and one to many relationships between Backbone models. Additionally, parent model instances (and objects extended from Backbone.Events) can listen in to CRUD events on any children – in the object graph – by providing an appropriately qualified even on deeply nested object graphs – and […]

Copy to clipboard using javascript(Zeroclipboard)

I tried so many ways to implement this, but found the below snippet very useful(using zeroclipboard.js) <html> <body> <script type=”text/javascript” src=”ZeroClipboard.js”></script> <script type=”text/javascript”> //set path ZeroClipboard.setMoviePath(‘ZeroClipboard.swf’); //create client var clip = new ZeroClipboard.Client(); //event clip.setHandCursor( true ); clip.addEventListener(‘mousedown’, function () { clip.setText(document.getElementById(‘box-content’).value); }); clip.addEventListener(‘complete’, function (client, text) { alert(‘copied: ‘ + text); }); //glue it […]

Shorten URL using Bitly in Rails 3.X

This is achieved by using an HTTP Redirect on a domain name that is short, which links to the web page that has a long URL. This is especially convenient for messaging technologies such as Twitter and Identical which severely limit the number of characters that may be used in a message. Many web developers […]

Scope in model Rails 3.X

Purspose Complex queries in controller make application hard to maintain. Move them into the model as named_scope or scope(Rails 3.X) make the controller simple and the complex find logics are all in models. Suppose we have in controller, class JobsController < ApplicationController     def index         @published_jobs = Job.find(:all, :conditions => { :status […]