Hello!
Unfortunately, you won't be able to use a mixin to access the methods that you want to actually create the database table. The create_table method can only be accessed through classes that inherit ActiveRecord::Migration.
I would suggest creating another class that inherits ActiveRecord::Migration and then setup some methods to set all of the attributes of the table. Once you've set that up then you can call the migrate method of the class and it will update the database.
# In controller class TableController < ApplicationController def create @results = CreateUsers.migrate(:up) end
class CreateUsers < ActiveRecord::Migration def self.up create_table .... end
def self.down drop_table .... end end end
Now if you're managing your database using migrations, I would not recommend updating the database inside the controller unless you save the migration to the filesystem and manage the versioning on the schema_info table.
Hope this helps.