Bases de datos no relacionales y Rails

September 11th, 2009 Comments off

README.md at 9202bd328b828159746bb902ef71690580313b2d from langalex’s couch_potato – GitHub:
CouchPotato es una capa de persistencia para CouchDB. CouchDB es, a su vez, una base de datos no relacional. Es un concepto bastante interesante.
Cito:
What CouchDB is

  • A document database server, accessible via a RESTful JSON API.
  • Ad-hoc and schema-free with a flat address space.
  • Distributed, featuring robust, incremental replication with bi-directional conflict detection and management.
  • Query-able and index-able, featuring a table oriented reporting engine that uses Javascript as a query language.
Categories: Ruby on Rails Tags:

Biblioteca para automatizar la interacción con websites

September 10th, 2009 Comments off

mechanize-0.9.3 Documentation:

The Mechanize library is used for automating interaction with websites. Mechanize automatically stores and sends cookies, follows redirects, can follow links, and submit forms. Form fields can be populated and submitted. Mechanize also keeps track of the sites that you have visited as a history.

Categories: Ruby, Ruby on Rails Tags:

Cómo debe ser el has_one asociado a un belongs_to :polymorphic

September 10th, 2009 Comments off

Cuando se tiene un belongs_to :polymorphic y se quiere poner un has_one en el modelo asociado, se debe hacer de la siguiente forma:

1
2
3
4
5
6
7
class AtributoObjeto < ActiveRecord::Base
  belongs_to :asociado, :polymorphic => true, :dependent => :destroy
end
 
class Myfile < ActiveRecord::Base
  has_one :atributo_objeto, :as => :asociado, :dependent => :destroy
end

Es decir, si el belongs_to se llama :asociado, el has_one debe escribirse como “:as => :asociado” para que Rails sepa que en el otro lado tiene que buscar un campo “asociado_type” y un “asociado_id”, en lugar de un “atributo_objeto_id”

Categories: Ruby on Rails Tags:

ActsAsReference: una mejor forma de tratar asociaciones polimórficas

September 10th, 2009 Comments off
Categories: Ruby on Rails Tags:
Recursos Rails