Ok this is happened to me a couple of times now and can''t seem to
figure out how or why. This goes back to my issue of creating tables
based off of an item that is created. First I have this code:
ActiveRecord::Schema.define do
create_table(itemtablename, :options => ''ENGINE=InnoDB
DEFAULT CHARSET=utf8'') do |t|
t.column :field_type, :string, :null => false
t.column :item_text, :text, :null => false
t.column :required, :tinyint, :null => false, :default =>
''0''
t.column :image, :text, :null => true
end
end
now I tried to use this statement in both my controller and my model:
ActiveRecord::ConnectionAdapters::SchemaStatements.create_table(
but I would get a undefined method `create_table'' for
ActiveRecord::ConnectionAdapters::SchemaStatements:Module error.
I am having the same issue with running the
ActiveRecord::ConnectionAdapters::DatabaseStatements.execute(
command. I am trying to add data to the table that i created and the
only way I can tell how to do that is by doing everything manual as
the table names are going to be changing based on what item the user
is creating or editing.
I am connecting to a MySQL 5 db which as of right now is what we plan
to run in production and I did install the mysql adapter (at least I
think I did as it told me I successfully installed it.)
How do I reference a different module?
sorry for the dumb question but this is really starting to get on my
nerves. I feel like I am so close yet so far away.
Andrew
why not just use one table to hold ALL items? then you don''t have to worry about all this dynamic table creation stuff. On 11/18/05, Andrew Filipowski <a.filipowski-ee4meeAH724@public.gmane.org> wrote:> > Ok this is happened to me a couple of times now and can''t seem to > figure out how or why. This goes back to my issue of creating tables > based off of an item that is created. First I have this code: > > ActiveRecord::Schema.define do > create_table(itemtablename, :options => ''ENGINE=InnoDB > DEFAULT CHARSET=utf8'') do |t| > t.column :field_type, :string, :null => false > t.column :item_text, :text, :null => false > t.column :required, :tinyint, :null => false, :default => ''0'' > t.column :image, :text, :null => true > end > end > > now I tried to use this statement in both my controller and my model: > > ActiveRecord::ConnectionAdapters::SchemaStatements.create_table( > > but I would get a undefined method `create_table'' for > ActiveRecord::ConnectionAdapters::SchemaStatements:Module error. > > I am having the same issue with running the > > ActiveRecord::ConnectionAdapters::DatabaseStatements.execute( > > command. I am trying to add data to the table that i created and the > only way I can tell how to do that is by doing everything manual as > the table names are going to be changing based on what item the user > is creating or editing. > > I am connecting to a MySQL 5 db which as of right now is what we plan > to run in production and I did install the mysql adapter (at least I > think I did as it told me I successfully installed it.) > > How do I reference a different module? > > sorry for the dumb question but this is really starting to get on my > nerves. I feel like I am so close yet so far away. > > Andrew > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Yeah, after rethinking the design of the database and the app this is the route I am going to go. Andrew On Nov 18, 2005, at 1:07 PM, Chris Hall wrote:> why not just use one table to hold ALL items? then you don''t have > to worry about all this dynamic table creation stuff. > > On 11/18/05, Andrew Filipowski < a.filipowski-ee4meeAH724@public.gmane.org> wrote: > Ok this is happened to me a couple of times now and can''t seem to > figure out how or why. This goes back to my issue of creating tables > based off of an item that is created. First I have this code: > > ActiveRecord::Schema.define do > create_table(itemtablename, :options => > ''ENGINE=InnoDB > DEFAULT CHARSET=utf8'') do |t| > t.column :field_type, :string, :null => > false > t.column :item_text, :text, :null => false > t.column :required, :tinyint, :null => > false, :default => ''0'' > t.column :image, :text, :null => true > end > end > > now I tried to use this statement in both my controller and my model: > > ActiveRecord::ConnectionAdapters:: SchemaStatements.create_table( > > but I would get a undefined method `create_table'' for > ActiveRecord::ConnectionAdapters::SchemaStatements:Module error. > > I am having the same issue with running the > > ActiveRecord::ConnectionAdapters:: DatabaseStatements.execute( > > command. I am trying to add data to the table that i created and the > only way I can tell how to do that is by doing everything manual as > the table names are going to be changing based on what item the user > is creating or editing. > > I am connecting to a MySQL 5 db which as of right now is what we plan > to run in production and I did install the mysql adapter (at least I > think I did as it told me I successfully installed it.) > > How do I reference a different module? > > sorry for the dumb question but this is really starting to get on my > nerves. I feel like I am so close yet so far away. > > Andrew > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
This is more a question for the more experienced among us: Are there any situations when dynamic table creation is a preferred technique? I have a sneaking suspicion that anything that can be done by dynamically creating tables can be replicated with a static structure, but is it ever better not to? -- Alex Andrew Filipowski wrote:> Yeah, > after rethinking the design of the database and the app this is the > route I am going to go. > > Andrew > > On Nov 18, 2005, at 1:07 PM, Chris Hall wrote: > >> why not just use one table to hold ALL items? then you don''t have to >> worry about all this dynamic table creation stuff. >> >> On 11/18/05, *Andrew Filipowski* < a.filipowski-ee4meeAH724@public.gmane.org >> <mailto:a.filipowski-ee4meeAH724@public.gmane.org>> wrote: >> >> Ok this is happened to me a couple of times now and can''t seem to >> figure out how or why. This goes back to my issue of creating tables >> based off of an item that is created. First I have this code: >> >> ActiveRecord::Schema.define do >> create_table(itemtablename, :options => >> ''ENGINE=InnoDB >> DEFAULT CHARSET=utf8'') do |t| >> t.column :field_type, :string, :null => >> false >> t.column :item_text, :text, :null => false >> t.column :required, :tinyint, :null => >> false, :default => ''0'' >> t.column :image, :text, :null => true >> end >> end >> >> now I tried to use this statement in both my controller and my model: >> >> ActiveRecord::ConnectionAdapters:: SchemaStatements.create_table( >> >> but I would get a undefined method `create_table'' for >> ActiveRecord::ConnectionAdapters::SchemaStatements:Module error. >> >> I am having the same issue with running the >> >> ActiveRecord::ConnectionAdapters:: DatabaseStatements.execute( >> >> command. I am trying to add data to the table that i created and the >> only way I can tell how to do that is by doing everything manual as >> the table names are going to be changing based on what item the user >> is creating or editing. >> >> I am connecting to a MySQL 5 db which as of right now is what we plan >> to run in production and I did install the mysql adapter (at least I >> think I did as it told me I successfully installed it.) >> >> How do I reference a different module? >> >> sorry for the dumb question but this is really starting to get on my >> nerves. I feel like I am so close yet so far away. >> >> Andrew >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> >> http://lists.rubyonrails.org/mailman/listinfo/rails > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails