rubyonrailsin

A Ruby and Rails talk

Monday, March 29, 2010


[Rails] How to use find method on table with two column index

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

I created an index with person_id and club_id but I can't figure out
how to properly access it (doesn't show up in the find_by... lists)

Can someone provide me a sample find statement to best use this index

Thanks.

class CreateMembers < ActiveRecord::Migration
def self.up
create_table :members do |t|
t.integer :club_id
t.integer :person_id
t.text :comment
t.string :status
t.string :member_type
t.integer :registrations_count

t.timestamps
end

add_index :members, :club_id
add_index :members, :person_id
add_index :members, [:person_id, :club_id]
end

def self.down
drop_table :members
end
end

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

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive