mercoledì 20 maggio 2009

Rails and mixed models convetions

I wrote a library for BioRuby to store data into BioSQL.  Evertything is fine, I hope :-), using the lib inside the BioRuby world but going outside and meeting rails, there is a crash.
BioSQL' schema doesn't follow the Rails' rules, because ... long story but that's it. Active record needs to be tuned, removing pluralization and changing the primary key structure:

self.pluralize_table_names = false
self.primary_key_prefix_type = :table_name_with_underscore

wow cool it's I can read my schema but ...
Using biosql into a rails app there is a problems, If you have tables which are referring/referred to/by  BioSQL schema you must specify the :class=>"Bio::SQL::XXX".
Then your notBioSQL tables loose their active record default properties like default primary keys and name convention. I had to re-setup them in every new table/class model.
That is very strange; I can't find an explenation but after days of trouble I got it. 
link_to method was my black doom.


Nessun commento:

Posta un commento