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
    create_table(:regular_ads) do |t|
      t.string : title
      t.float : price
      t.string : content
      t.string : username
      t.integer : from
      t.integer: to
    end
  end
end



On Feb 8, 6:10 pm, regedarek <[email protected]> wrote:
> I would like to use only one table ads on database.
>
> regular AD:
>
> >   :title
> >   :price
> >   :content
> >   :username
>
> > trip AD:
> >   :title
> >   :price
> >   :content
> >   :username
> >   :from
> >   :to
>
> Which associations should I use?
>   Polymorphic Associations
>   The has_and_belongs_to_many
>   Else?

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to