Skip to content

Instantly share code, notes, and snippets.

View fellix's full-sized avatar

Rafael Felix fellix

View GitHub Profile
@fellix
fellix / collections.js
Created July 19, 2011 13:18
backbone sample
window.AlbumsCollection = Backbone.Collection.extend({
model: Album,
initialize: function(collection_id){
this.url = '/collection/'+collection_id+"/albums";
}
});
@fellix
fellix / backbome model.js
Created July 19, 2011 13:12
backbone sample
window.Album = Backbone.Model.extend({
url: function(){
return this.id ? '/collection/'+this.album_collection_id+'/album/'+this.id : '/collection/'+this.album_collection_id+'/albums';
},
defaults: { album: {
album_collection_id: 0,
title: "nothing",
artist: "nobody",
image: "",
price: 0.0,
@fellix
fellix / Gemfile
Created July 6, 2011 12:10
JasmineRice
group :development, :test do
gem 'rspec-rails'
gem 'shoulda'
gem 'jasmine'
gem "jasminerice"
end
@fellix
fellix / gist:1031301
Created June 17, 2011 12:14
JSON Export
File.open( 'a.json', 'w') { |f| f.write Imovel.all.to_json(:include => {:videos => { :except => :updated_at }, :fotos => {:methods => :public_filename} }) }
def self.find_by_url(friendly_id)
result = self.joins("JOIN slugs ON slugs.sluggable_id = posts.id and slugs.sluggable_type = 'Post'").where("slugs.name = ?", friendly_id).first
raise ActiveRecord::RecordNotFound unless result
result
end
def show
@post = Post.find params[:id]
end
@fellix
fellix / gist:803379
Created January 30, 2011 23:03
discus error
/home/suerafa/.rvm/gems/ruby-1.9.2-p136@1_9_2_gemset/gems/json-1.5.1/lib/json/common.rb:66: [BUG] unknown type 0x22 (0xc given)
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-linux]
-- control frame ----------
c:0053 p:---- s:0173 b:0173 l:000172 d:000172 CFUNC :initialize
c:0052 p:---- s:0171 b:0171 l:000170 d:000170 CFUNC :new
c:0051 p:0099 s:0168 b:0166 l:000165 d:000165 METHOD /home/suerafa/.rvm/gems/ruby-1.9.2-p136@1_9_2_gemset/gems/json-1.5.1/lib/json/common.rb:66
c:0050 p:0208 s:0157 b:0156 l:000155 d:000155 CLASS /home/suerafa/.rvm/gems/ruby-1.9.2-p136@1_9_2_gemset/gems/json-1.5.1/lib/json/ext.rb:24
c:0049 p:0011 s:0154 b:0154 l:000153 d:000153 CLASS /home/suerafa/.rvm/gems/ruby-1.9.2-p136@1_9_2_gemset/gems/json-1.5.1/lib/json/ext.rb:6
c:0048 p:0021 s:0152 b:0152 l:000151 d:000151 TOP /home/suerafa/.rvm/gems/ruby-1.9.2-p136@1_9_2_gemset/gems/json-1.5.1/lib/json/ext.rb:3