Having a scope called `parents` breaks acts_as_nested_set

I started to get this weird error with my categories today.

It was sort of ridiculous because I had only changed my scope name from ‘parent’ to ‘parents’!

That was the problem.

acts_as_nested_set, v1.4.4, breaks if you name a scope ‘parents.’

You will get an error like this:

undefined method `const_defined?’ for #<Category:0x112ccfdb8>

Posted in open source, Ruby programming, web programming | Tagged , , , | Leave a comment

Censo 2010 API: Qué métodos ofrecer

Quizás lo más difícil de construir una API es definir qué métodos proveer. Estos dependen de los datos que tenemos.

Para el caso de Censo 2010, la información scrapeada del INDEC solo contiene datos de población en el país. (Por lo menos por ahora)

Elegí proveer métodos básicos para consultas sobre población por departamento o provincia.

Por ejemplo:

GET /poblacion/buenos_aires/san_nicolas

Devuelve todos los datos de población detallados (edad, cantidad de hombres, cantidad de mujeres) del departamento de San Nicolás, Buenos Aires.

Este método no realiza ningún cálculo, solo expone los datos del Censo 2010 en JSON, para ser procesados por otros programas.

Para ver solamente los totales, podemos hacer:

GET /poblacion/buenos_aires/san_nicolas/totales

Esto solo mostrará el total de mujeres y varones en San Nicolás, Buenos Aires.

Sé que el formato no es amigable al ojo no técnico, pero hay formas simples de tomar esa información y mostrarla ‘amigablemente‘. (y estoy trabajando en eso)

Acá (http://censo.heroku.com) pueden ver los métodos que desarrollé y acá el código detrás de la API (https://github.com/etagwerker/censo2010/blob/v2/site.rb#L51)

¿Simple, no?

Posted in open source, Ruby programming, web programming | Tagged , , , , | Leave a comment

How to push a particular branch to Heroku

This is just a shortcut to a command I found here: http://devcenter.heroku.com/articles/git

This is my .git/config:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[core]
  repositoryformatversion = 0
  filemode = true
  bare = false
  logallrefupdates = true
  ignorecase = true
[heroku]
  account = personal
[remote "heroku"]
  url = git@heroku.personal:censo2010.git
  fetch = +refs/heads/*:refs/remotes/heroku/*
[remote "origin"]
  url = git@github.com:etagwerker/censo2010.git
  fetch = +refs/heads/*:refs/remotes/origin/*
[remote "production"]
  url = git@heroku.personal:censo.git
  fetch = +refs/heads/*:refs/remotes/production/*

In order to push the “v2branch to the Heroku “productionremote, this is the command I use:

1
  $ git push production v2:master

I need to do this because:

This will probably change soon. I’ll most likely turn the “master” branch into the “v1″ branch.

Posted in developer tools, linux/unix world, programming, web programming | Tagged , , , , , , , , | Leave a comment