Forum: Ruby on Rails Severe STI, HABTM with Attributes and 1.1

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0ff4b2f49c3df249959a4560c0e16510?d=identicon&s=25 Paul (Guest)
on 2006-04-23 21:02
(Received via mailing list)
All,

I had been working on a project that was using STI to a very high
degree. It also was using a HABTM table that had a couple extra
attributes. It seems that with 1.1 push_with_attributes is deprecated
and I am having a bit of trouble moving things to using has_many
:through

The original schema I had worked like this :

create_table "nodes" do |t|
  t.column "title", :string
  t.column "body", :integer
  t.column "type", :string
end

create_table "nodes_to_nodes", :id => true, :primary_key => "n2n_id",
:force => true do |t|
  t.column :node_id, :integer, :default => 0, :null => false
  t.column :node_fk_id, :integer, :default => 0, :null => false
  t.column :position, :integer
  t.column :foreign_type, :string
end

class NodesToNodes < ActiveRecord::Base
  set_primary_key :c2c_id
  acts_as_list :scope => :node
end

So basically I could have all sorts of Node types that used STI off
the original Node table. And the if Foo < Node and Bar < Node I could
set in Foo's model that it HABTM Bars and at the same time order the
Bars that Foo had.

Now without push_attributes I can't see how I can replicate the same
thing using :through

Am I going to have to use STI on NodesToNodes as well? Set up
FooToBars < NodesToNodes?

Any other thoughts? It was working quite well but I'd hate to have to
sit and use 1.0 forever.

I checked out hasmanythrough.com and kind of get what it talks about
with self-referential tables, but it doesn't seem to all fit once STI
is introduced.

Thanks for any help and thoughts.

-Paul
This topic is locked and can not be replied to.