i’ trying to re-create my project from php to rails. But now Im faced with a pb to witch I had solution with php, but I cant figure how to make it work with rails
here my tables
here what I succeed to do
class Ad < ActiveRecord::Base
attr_accessible :category_id :title, :text, :ad_real_estate_details
accepts_nested_attributes_for :ad_real_estate_details, allow_destroy: true
class AdRealEstateDetail < ActiveRecord::Base
validates :ad_id, presence: true
but this only work for other category than real_estate
so I was thinking of polymorphism, but polymorphism mean I should add a reference in my “ad” table to the detail tables, and remove annonce_id from detail tables , what I thing is non-sense as some ads can have no details, but details are non-sense without an ad.
I was also thinking of a class AdDetails, and AdRealEstateDetail would inherite from it, but this is not possible with rails as all subclasses will share the same table
does anyone have a solution for this kind of problem ?