Here are my models:
class BillingProfile < ActiveRecord::Base
belongs_to :student
attr_accessible :cost
end
class PerEventBillingProfile < BillingProfile
belongs_to :event_category
end
class FlatFeeBillingProfile < BillingProfile
attr_accessible :interval, :frequency
end
Students can have many billing profiles of both types. What I'd like is a radio button in my student creation form that lets the user choose between creating a PerEventBillingProfile and a FlatFeeBillingProfile. When the per event radio is chosen, fields for a PerEventBillingProfile would show up, and vice versa. In order to get that to happen with this model setup, it appears I'd have to do:
class Student < ActiveRecord::Base
has_many :per_event_billing_profiles
has_many :flat_fee_billing_profiles
accepts_nested_attributes_for :per_event_billing_profiles
accepts_nested_attributes_for :flat_fee_billing_profiles
end
It feels like this could be simpler. Is there a more straightforward way to get what I want? I realize that I could stuff all of this into one model and just have a bunch of NULL values in my columns, but I don't like that either.