Ruby on Rails
Monday, January 28, 2013
On Sun, Jan 27, 2013 at 11:27 PM, oto iashvili <optimum.dulopin@laposte.net> wrote:
hi,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 railshere my tablesadsidcategory_idtitletextad_real_estate_detailsidad_idnb_roomfloorad_car_detailsidad_idcolorbrandhere what I succeed to doclass Ad < ActiveRecord::Baseattr_accessible :category_id :title, :text, :ad_real_estate_details
This should be :add_real_estate_details_attributes
has_one :ad_real_estate_detailsaccepts_nested_attributes_for :ad_real_estate_details, allow_destroy: trueendclass AdRealEstateDetail < ActiveRecord::Basebelongs_to :advalidates :ad_id, presence: trueendbut this only work for other category than real_estateso 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 tabledoes anyone have a solution for this kind of problem ?thanks--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/GLpFbbHm0ogJ.
For more options, visit https://groups.google.com/groups/opt_out.
Nicolas Desprès
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment