Skip to content

Instantly share code, notes, and snippets.

# More "proper" than a miniskirt (http://gist.github.com/273579).
class Minidress
@@factories = {}
class << self
def define(name, &block)
@@factories[name.to_s] = block
end
def build(name, attrs = {})
new(name.to_s.classify.constantize.new, &@@factories[name.to_s]).record
# Factory girl, relaxed.
#
# Factory.define :user do |f|
# f.login 'johndoe%d' # Sequence.
# f.email '%{login}@example.com' # Interpolate.
# f.password f.password_confirmation('foobar') # Chain.
# end
#
# Factory.define :post do |f|
# f.user { Factory :user } # Blocks, if you must.
@pacoguzman
pacoguzman / jquery-1-4-hawtness-1-with-paul-irish.js
Created January 31, 2010 16:02
jQuery Hawtness with Paul Irish
// http://pastie.org/783420.
// view the full video at:
// http://jquery14.com/day-05/jquery-1-4-hawtness-1-with-paul-irish
/* d8b .d88888b. d888 d8888
Y8P d88P" "Y88b d8888 d8P888
888 888 888 d8P 888
8888 888 888 888 888 .d88b. 888d888 888 888 888 d8P 888
"888 888 888 888 888 d8P Y8b 888P" 888 888 888 d88 888
888 888 Y8b 888 888 888 88888888 888 888 888 888 8888888888
@pacoguzman
pacoguzman / graffities_controller_spec.rb
Created February 11, 2010 10:59
Ejemplos Testing en Ruby y Rails con Rspec
require 'spec_helper'
describe Member::GraffitiesController do
context "A anonymous user" do
it "denies access to create action" do
@controller.expects(:create).never
post :create, {:wall_id => 1}
end
# Directly copied from eycap-0.5.2 (thanks!)
#
# With these tasks you can:
# - dump your production database and save it in shared_path/db_backups
# - dump your production into your local database (clone_to_local)
#
# Right now is not tested without all the gem. Give me a moment to check it :-)
Capistrano::Configuration.instance(:must_exist).load do
namespace :db do
@pacoguzman
pacoguzman / Rails 3
Created March 27, 2010 09:42
Cosillas no vistas anteriormente
* 2010_06_26 - Cosillas Raras de Arel - https://rails.lighthouseapp.com/projects/8994/tickets/4841-multiple-select-only-keep-the-last-one
- Si usas varios select separados se concatenan Post.select("title").select("autor")
- Si usas varios order seaparados se concatenan Post.order("title").order("autor")
- Puedes utilizar reorder para sobreescribier Post.order("title").reorder("autor")
* 2010_06_09 - Al pareacer en i18n si se necesita un string html_safe la clave debe acabar en _html o en .html ActionView::Helpers::TranslationHelper doc
* 2010_04_10 - Fuera del core los helpers que pintan los errores ahora http://github.com/rails/dyanimic_form
* 2010_04_10 - Fuera del core de rails verify (in controllers) ahora http://github.com/rails/verification
* 2010_04_05 - Added all the new HTML5 form types as individual form tag methods (search,
url, number, etc) - http://github.com/rails/rails/commit/f8730e5ce6bba4de7639ac09c6c193458038f748#comments
@pacoguzman
pacoguzman / rails_3_beta2_changes
Created April 2, 2010 10:29 — forked from ryanb/rails_3_beta2_changes
Rails3 Beta 2 changes
Action Pack
* Remove metal from Rails3 [YK]
http://github.com/rails/rails/commit/45e60283e733a535d68d499aa20e095c905f43b0
* :only and :except options in the use of rack middlewares [JV]
http://github.com/rails/rails/commit/9a93844aba44319d3c8487a554124beb00ccc267
class PostsController < ApplicationController
use AutheMiddleware, :except => [:index, :show]
Factory.define :application do |factory|
factory.attachment(:sample, "public/samples/sample.doc", "application/msword")
end
@pacoguzman
pacoguzman / I18n devise es
Created June 22, 2010 07:40
devise I18n file in spanish
es:
errors:
messages:
not_found: 'no encontrado'
already_confirmed: 'ya ha sido confirmada'
not_locked: 'no está bloqueada'
devise:
failure:
unauthenticated: 'Necesitas acceder a tu cuenta o registrarte antes de continuar.'
@pacoguzman
pacoguzman / instalación ubuntu
Created October 8, 2010 14:09
Instalación Básica Ubuntu - RoR
# Development
sudo apt-get install bash-completion autoconf tig meld curl subversion git-core git-svn git-cola gitg xchat postfix
# Chrome
http://google.com/chrome
# Sun Java
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk