How to tell DataTable to handle associated data tables?

How to tell DataTable to handle associated data tables?

rixterrixter Posts: 3Questions: 0Answers: 0
edited August 2012 in Editor
I cannot seem to find the answer to this simple need: how to tell Rails, and hence DataTables, about related data tables?

I am not too experienced in Rails yet, so am still learning about the various find() methods for telling ROR about related data using Active Record; but the essence of my task is to display (using the index.html.erb view file) data from three tables: genotypes, gmarkers and gvision.

The models are constructed like:
class Gmarker < ActiveRecord::Base
attr_accessible :marker
has_many :genotypes, :dependent => :delete_all

...
class Genotype < ActiveRecord::Base
attr_accessible :allele1, :allele2, :run_date
belongs_to :gmarkers
belongs_to :gsamples
...
class Gsample < ActiveRecord::Base
belongs_to :gupload
has_many :genotypes, :dependent => :delete_all
attr_accessible :box, :labid, :subjectid, :well


As can be seen in this error message output from the webserver, the problem lies in not getting the correct data associations:
...
CACHE (0.0ms) SELECT COUNT(*) FROM "genotypes"
Genotype Load (10.5ms) SELECT "genotypes".* FROM "genotypes" ORDER BY allele1 asc LIMIT 10 OFFSET 0
Completed 500 Internal Server Error in 255ms

NameError (undefined local variable or method `f' for #):
app/datatables/genotypes_datatable.rb:24:in `block in data'
app/datatables/genotypes_datatable.rb:21:in `data'
app/datatables/genotypes_datatable.rb:14:in `as_json'
app/controllers/genotypes_controller.rb:7:in `block (2 levels) in index'
app/controllers/genotypes_controller.rb:5:in `index'
...

Can anybody help to elucidate where the call to DataTables went awry? Where is this configured? (even if not in DataTables)

Thanks,
Rick Casey

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Hi Rick,

    Although there are a few people in this forum with Rails expertise, I think you might be better off asking this one in a Rails forum (or perhaps SO?). I don't know much about Rails myself so I can't really offer any help regarding a server-side script in Rails.

    Allan
  • rixterrixter Posts: 3Questions: 0Answers: 0
    edited August 2012
    Thanks Allen. Good advice! will do....
This discussion has been closed.