I am a RAILS beginner and have been building an application that has quite a few models in it. The problem I encounter is the following:
There are three models: Contig, Intergenic, Longshortgene
A contig has many intergenics and many longshortgenes.
One of the fields in Intergenic is of the form A-B, where A and B are Longshortgene objects.
From the intergenics view, I would like to use A and B, in separate calls, to find any longshortgenes that have the same geneid (A or B) and belong to the same contig as the intergenics object.
My intergenics controller's "show" method is as follows:
def show @intergenic = Intergenic.find(params[:id])
email@example.com('-') genearr.each do |gene| @longgenes = @intergenic.ls_neighborhood(gene, 'LONG') @shortgenes = @intergenic.ls_neighborhood(gene, 'SHORT') render :action => 'list' end
My model intergenic.rb contains the following:
def ls_neighborhood(geneid,genetype) Longshortgene.find_by_sql["select l.geneid from longshortgenes l where l.geneid=? and l.contig_id=? and l.genetype=?",geneid,contig_id,genetype] end
From the "show" view, I just try to access @longgenes and @shortgenes and do something with them.
Until I inserted the above blocks of code, my application was functional. Now I get the following error:
ArgumentError in IntergenicsController#show
wrong number of arguments (4 for 1)
RAILS_ROOT: /Users/apati/Projects/qa Application Trace | Framework Trace | Full Trace
app/models/intergenic.rb:6:in `find_by_sql' app/models/intergenic.rb:6:in `ls_neighborhood' app/controllers/intergenics_controller.rb:27:in `show' app/controllers/intergenics_controller.rb:26:in `each' app/controllers/intergenics_controller.rb:26:in `show'
Could someone please point out what I am doing wrong?
Thank you very much!