[Rails] Re: Which associations should I use? to extend ad model.

2012-02-09 Thread regedarek
I think form me i should be something like this below because I need different validations to each type of ads. Or in your example could i set up this kind of different validations? class Ad ActiveRecord::Base validates_presence_of :name, :email, :price(?), :category_id(?) :name

[Rails] Re: Which associations should I use? to extend ad model.

2012-02-08 Thread regedarek
I create a Gist with my recent ideas: https://gist.github.com/1770515 ** http://groups.google.com/group/rubyonrails-talk?hl=pl -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To view this discussion on the web visit

[Rails] Re: Which associations should I use? to extend ad model.

2012-02-08 Thread gerbdla
what are the other objects? What is it that has_and_belongs_to_many? for polymorphic relationships you want to ask if more than one So class Ad belongs_to :adable, :polymorphic = true end class Customer has_many :ads, :as = :adable end class NewsPaper has_many :ads, :as=:adable end At

[Rails] Re: Which associations should I use? to extend ad model.

2012-02-08 Thread Erwin
STI , Single Table Inheritance (This structure is best used for models that have identical, or very similar attributes ) trip AD regular AD class RegularAd ActiveRecord::Base end class TripAd RegularAd end migration (Rails 3.1) class CreateAds ActiveRecord::Migration def change