domenica 31 maggio 2009

Rails, form_remote_tag, method GET

This is not a bug, just a reminder for me on HowTo set up a form_remote_tag with method GET on Rails, I'm using version 2.2.2
The only things bugged here is the documentation bevause is not very intuitive. There are a lot of examples but none about setting the method to GET. This snippet sets the ajax request and the html request to GET. Don't forget to set both to get, otherwise you'll have a for with an ajax get and a html post, POST is the DEFAULT.

     form_remote_tag  :url => blasts_path,
                        :method => :get,
                        :html => {:method=> :get},
                        :update => { :success => "succeed", :failure => "fail"} do 

....YOUR CODE  HERE....

       select("sm","id", {"SeMe clusters"=>"1", "All clusters"=>"0"}) 
       submit_tag "Search", :name => nil 
    end 

      
    

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.


When your Boss became a Parrot

There is always a bug and it's quite stressing when you find it, why ?
Usually happends when you have no time or your boss is over your shoulder wating for your answer. You are the Tree and he is the Parrot.

Discovering and resolve bugs is very interesting, keep your bain young and imply a lot of work for Google.

I'm working with a lot of technologies, Ruby, Rails, DB Postgresql and MySQL,  JEE, Hibernate, bioinformatic tools. 
Everything is like a mine field. The Parrot in this case is flying over your head.