File this under mild pedantry, but it's been bugging me.  Assume I want
to store different kinds of fruit in an STI table.  My approach works,
but I end up referring to "fruit_bases" throughout my code where I'd
really prefer just "fruits".

What I've got is something like:
=============
# File: db/schema.rb
create_table "fruit_bases" do |t|
  t.string "type"
  t.id "basket_id"
end

# File: app/models/fruit.rb
module Fruit
  def self.table_name_prefix
    'fruit_'
  end
  require 'fruit/base'
end

# File: app/models/fruit/base.rb
module Fruit
  class Base < ActiveRecord::Base
    belongs_to :basket
    # code common to all fruit
  end
end

# File: app/models/fruit/apple.rb
module Fruit
  class Apple < Base
    # apple specific code
  end
end

# File: app/models/basket.rb
class Basket < ActiveRecord::Base
  has_many :fruit_bases
end
=============

Instinct tells me that my table should be named simply "fruits", and
that a Basket has_many :fruits, not :fruit_bases.

What's the rails-y way to accomplish that?

- ff

-- 
Posted via http://www.ruby-forum.com/.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to