A
aktxyz
Rails has a very nice database migration utility, where you can write
something like this...
class CreateHouse < ActiveRecord::Migration
def self.up
create_table :house do |t|
t.column 'person_id', :integer, :default => nil, :null => false
t.column "created_at", :datetime
t.column "name", :string, :limit => 128, :default => ""
end
end
def self.down
drop_table lace
end
end
Typically, you then create a class in the model directory that looks
like this...
class House < ActiveRecord::Base
belongs_to erson
end
I'd like to dynamicallly generate this House class. With the help of
this post, I can create the class and methods dynamically...
http://groups.google.com/group/comp...nk=gst&q=create+class&rnum=8#b8d076423378a2f2
But I have not been able to figure out how to add the belongs_to and
has_many style calls at the class level to the dynamicall generated
class. Also, once this class is initially created dynamically,
depending on what tables are created later, there may have to be
additional belongs_to and has_many calls injected into the existing
class, whew.
-- any help would be great, thanks, Andrew
something like this...
class CreateHouse < ActiveRecord::Migration
def self.up
create_table :house do |t|
t.column 'person_id', :integer, :default => nil, :null => false
t.column "created_at", :datetime
t.column "name", :string, :limit => 128, :default => ""
end
end
def self.down
drop_table lace
end
end
Typically, you then create a class in the model directory that looks
like this...
class House < ActiveRecord::Base
belongs_to erson
end
I'd like to dynamicallly generate this House class. With the help of
this post, I can create the class and methods dynamically...
http://groups.google.com/group/comp...nk=gst&q=create+class&rnum=8#b8d076423378a2f2
But I have not been able to figure out how to add the belongs_to and
has_many style calls at the class level to the dynamicall generated
class. Also, once this class is initially created dynamically,
depending on what tables are created later, there may have to be
additional belongs_to and has_many calls injected into the existing
class, whew.
-- any help would be great, thanks, Andrew