On Mon, Aug 16, 2010 at 12:21 PM, voobles <[email protected]> wrote:
> indeed it works the way you described it Matt! Thanks.
>
> just to clarify, what i tried, was to use habtm with :index,
> ie.
> has_and_belongs_to_many :model_name, :index => 'some_field_name'
>

Ah, got it. There's not support for naming an index on the habtm
model; actually, it looks like HabtmModelShim (in
migration_generator.rb) explicitly declares *no* indexes, so the
generator might even try to drop existing ones.

Would it be reasonable to read the above as indexing the corresponding
foreign key in the join table? Thus:

class A < AR::Base
  habtm :bs, :index => 'index_foo'
end

class B < AR::Base
  habtm :as, :index => 'index_bar'
end

would give (in the migration):

add_index :as_bs, :a_id, :name => 'index_foo'
add_index :as_bs, :b_id, :name => 'index_bar'

Thanks,

--Matt Jones

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" 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/hobousers?hl=en.

Reply via email to