I have a simple has_many/belongs_to relationship between Report and Chart. The issue I'm having is that my Chart model is a parent that has children.
So in my Report model I have
class Report < ActiveRecord::Base
has_many :charts
end
And my Chart model is a parent, where Pie, Line, Bar all inherit from Chart. I'm not sure where the belongs_to :report belongs within the chart model, or children of chart model. I get errors when I attempt to access chart.report because the object is of type "Class"
undefined local variable or method `report' for #< Class:0x104974b90>
The Chart model uses STI so its pulling say.. 'Gender' from the chart_type column in the charts table.. what am I missing?
EDIT
Chart
/ \
Pie Line
/ \
/ \
Gender Sex
I am (using STI) instantiating an object of type Gender, or Sex. Hopefully this helps a bit more.
I have a feeling that its caused by
@chart.update_attributes(params[:chart])
because when submitted its actually params[:chart] its params[:gender] or params[:sex]