Skip to content

Instantly share code, notes, and snippets.

View gonzalo-bulnes's full-sized avatar

Gonzalo Bulnes Guilpain gonzalo-bulnes

View GitHub Profile
#Load in rails via:
# config/initializers/core_extensions.rb
#Forcibly require our core extensions after rails has loaded
Dir.glob(Rails.root.join('lib', 'core_ext', '*.rb')).each { |extension| require extension }
@gonzalo-bulnes
gonzalo-bulnes / work_place_spec.rb
Created April 10, 2013 23:28
Using lambda functions to test exception raising with RSpec.
require 'spec_helper'
describe WorkPlace do
# This is the simplest (best) way to test a dependent: :destroy option
it "has one address and ensures it's destroyed when destroyed itself" do
should have_one(:address).dependent(:destroy)
end
# ... however the use this example does of lambda {} to encapsulate the code
es:
errors:
messages:
not_found: "no encontrado"
already_confirmed: "ya ha sido confirmado"
not_locked: "no está bloqueado"
devise:
sessions:
link: 'Ingresar'
# acid-template.rb
git :init
gitignore = run("curl https://gist.github.com/raw/3875160/5d2745ee9bcae0bb4addf4bc701d3fa9a48ce187/.gitignore")
file ".gitignore", gitignore
if yes?("Do you use RVM? (yes|no")
if yes?("Do you want to create a .rvmrc file for the project? (yes|no)")
# RVM
current_ruby = %x{rvm list}.match(/^=>\s+(.*)\s\[/)[1].strip
desired_ruby = ask("Which RVM Ruby would you like to use? [#{current_ruby}]")
@gonzalo-bulnes
gonzalo-bulnes / comunas.json
Last active April 4, 2023 18:48
Comunas de Chile (seed Ruby on Rails, JSON) - (see also https://github.com/gonzalo-bulnes/chilean_cities)
[
{
"name": "Arica",
"code": "15101",
"provincia": "Arica",
"region": "Arica y Parinacota",
"region_number": "XV",
"region_iso_3166_2": "CL-AP"
},
{