Skip to content

Instantly share code, notes, and snippets.

View vinniefranco's full-sized avatar
🏡
WFH

Vincent Franco vinniefranco

🏡
WFH
View GitHub Profile
class Admin::PostsController < ApplicationController
before_filter :authenticate_user!
respond_to :json
def index
@posts = Post.asc(:created_at)
respond_with(@posts)
end
[INFO] firing openInit
[INFO] inside init.js
[INFO] Available memory: 1178.80859375
callback = gotInfo;
method = "account.getInfo";
}
[INFO] ***********************************************************start
[INFO] ----------------------------------------------------------------
[INFO] >>> openConnection :: Mon Dec 20 2010 10:39:09 GMT-0800 (PST)
[INFO] ----------------------------------------------------------------
class Example
def initialize(name)
# this means there is an instance var of name in this object.
@name = name
end
# This is the ruby equivilant to this JS class method
#
class Article < ActiveRecord::Base
def image=(file)
uploader = ArticleUploader.new
uploader.store!(file)
self.small = uploader.small.url
self.original = uploader.url
end
We couldn’t find that file to show.
@vinniefranco
vinniefranco / gist:786620
Created January 19, 2011 18:44
Fixes :limit => 0 for enumerated columns in rails 3
# Fixes :limit => 0 on enumerated columns, now you can test!
module ActiveRecord
module ConnectionAdapters
class Column
def extract_limit_with_enum(sql_type)
sql_type.scan(/enum/i)? 255 : extract_limit_without_enum(sql_type)
end
alias_method_chain :extract_limit, :enum
end
end
json.gallery do |g|
g.info do |info|
info.title @gallery.title if @gallery.title
info.image @gallery.image.l(:medium) if @gallery.image
info.parent_id @gallery.parent_id if @gallery.parent_id
info.root true unless @gallery.parent_id
end
@gallery.photos.each do |photo|
g.photos do |p|
p.id photo.id
var Layout = (function() {
/*
TODO Maybe some default modules?
*/
var modules = modules || {};
function addModule(name, callback) {
modules[name] = callback;
}
function applyJSON(json) {
var Gallery = (function() {
var opts = {},
cont = {};
function displayMeta (data) {
if ( ! data.info) { opts.html(''); return; }
var meta = data.info,
str = "<img src='"+meta.image+"'><h3>"+meta.title+"</h3>";
class PhotoGallery < ActiveRecord::Base
# Legacy work
self.inheritance_column = 'inheritance_type'
set_table_name :galleries
alias_attribute :created_at, :dcreate
belongs_to :client,
:conditions => { :table_name => :galleries,
:type => :photos }