Ruby on Rails Thursday, April 29, 2010

> Thank you all, so very much, for your great, thoughtful posts and solid
> advice. You all have excellent points. I've decided to take your advice
> as wise council, and stick with the single-table model. :)

Hi,

if you find you *DO* have to shard in your application, then I used
the approach:

todo_items_<user_id>

and created a base level todo_items (which held no values) and created
the tables todo_items_<user_id> with the MySQL statement:

create table todo_items_<user_id> like todo_items

Migration can be a bit of a pain though!

Once you know the user_id in your controller the you can just do

TodoItem.set_table_name "todo_items_#{@user.id}"

Just my 2 pennies worth

Allan

--
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