I'm working on a website which allows users to upload lots of specific
information. Due to the amount of data, I wanted to give each user
their own table for this data. I started off looking at this thread:
http://railsforum.com/viewtopic.php?pid=72581
Im able to generate the table, but I get the unitialized constant
error when I try to use the new table/model without restarting
webrick.
I wanted to reload the schema if a constant isn't found, so I used
this block of code:
begin
@log_table = "user_#{current_user.id.to_s}_logs"
@log_table = @log_table.camelize.classify.constantize
rescue NameError
schema = DrNicMagicModels::Schema.new(Object)
DrNicMagicModels::Schema.class_eval "@@models = nil"
schema.load_schema
@log_table = "user_#{current_user.id.to_s}_logs"
@log_table = @log_table.camelize.classify.constantize
end
Looking at the webrick output, I can see it finding the new table:
Got a model table: user_15_logs => class User15Log
But Im still getting the error:
uninitialized constant User15Log
I'm shooting in the dark a little bit with this, but I would
appreciate any input. Also, is it possible to reload only a certain
table? I went this route because the amount of data in one table will
not scale, breaking it out into seperate tables helps. I'm worried
that reloading an entire schema, with too many tables will run into
the same scaling problem. Being able to add a specific model would be
perfect.
Thanks