Skip to content

Instantly share code, notes, and snippets.

View carlosbrando's full-sized avatar

Carlos Brando carlosbrando

View GitHub Profile
class Post < ActiveRecord::Base
has_many :comments
def comments=(attrs_array)
attrs_array.each do |attrs|
comments.create(attrs)
end
end
end
render :template => "weblog/show", :locals => {:customer => Customer.new}
What's new in Rails 2.0.4
-------------------------
Action Mailer
* Less verbose mail logging: just recipients for :info log level; the whole email for :debug only. #8000 [iaddict, Tarmo Tänav]
* Updated TMail to version 1.2.1 [raasdnil]
* Fixed that you don't have to call super in ActionMailer::TestCase#setup #10406 [jamesgolick]
Action Pack
* All 2xx requests are considered successful [Josh Peek]
* Deprecate the limited follow_redirect in functional tests. If you wish to follow redirects, use integration tests. [Michael Koziarski]
* Fixed that AssetTagHelper#compute_public_path shouldn't cache the asset_host along with the source or per-request proc's won't run [DHH]
* Deprecate define_javascript_functions, javascript_include_tag and friends are much better [Michael Koziarski]
@carlosbrando
carlosbrando / gist:10861
Created September 15, 2008 13:56 — forked from Neto/gist:10791
CmdUtils.CreateCommand({
name: "viu",
icon: "http://www.viuisso.com.br/favicon.ico",
author: {name: "Mentor Muniz", email: "neto@bullet.com.br"},
description: "Viu Isso? Search",
homepage: "http://www.viuisso.com.br/",
takes: {"query": noun_arb_text},
execute: function (q) {
# Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html
Olá, Eu sou Chris Wanstrath.
Quando Jeremy me chamou para falar, eu disse sim. Maldição, eu disse sim.
Imediatamente. Mas, depois que parei para pensar, Espera, por quê? Por que eu?
O que eu vou dizer de interessante? Alguma coisa sobre Ruby, talvez. Talvez,
sobre o futuro dele. Ou o futuro de algo, pelo menos. Isto soa como um
keynote-y.
class NilClass
def to_s
"n/a"
end
end
@carlosbrando
carlosbrando / gist:24491
Created November 13, 2008 16:47
Silent method
def silent(command)
system "#{command} &> /dev/null"
end
silent "git add ."
class Object
def try(method_id, *args, &block)
respond_to?(method_id) ? send(method_id, *args, &block) : nil
end
end
require 'rubygems'
require 'spec'
describe Object, "#try" do
(function($){
$.fn.defaultValueActsAsHint = function() {
return this.each(function() {
$(this).attr('_default', $(this).attr('value'))
$(this).addClass('hint');
$(this).bind('focus', function(event) {
if ($(this).attr('_default') == $(this).attr('value'))
$(this).removeClass('hint').attr('value', '');
});