Topic: db:schema:load - ActionController
Just started using Rails and had a question running a rake task from a Controller.
I need the ability to create a new schema on demand from a UI.
I've seen the following suggestions.
Rake::Task['db:schema:load'].invoke : runs and does nothing
system('rake db:schema:load') : runs & fails as it appears to be picking up the environment.rb and trying to drop and recreate the existing database specified there.
ActiveRecord::Base.connection.execute("create schema " + schema) ActiveRecord::Base.connection.execute("CREATE TABLE " + schema + ".some_table LIKE some_schema.some_table")
but I'm sure there's a better way to skin this cat.
Last edited by sthomps (2013-03-06 12:08:10)