Generate migration in a template

10 views
Skip to first unread message

Jonathan Allard

unread,
Sep 8, 2016, 2:40:23 PM9/8/16
to Ruby on Rails: Talk
I discovered application templates today, and I've been banging my head against the wall for an hour now about generating a one-line migration.

g = Rails::Generators::Base.new
g
.extend Rails::Generators::Migration
g
.instance_variable_set(:@source_paths, [File.expand_path(File.dirname(__FILE__))])

g
.migration_template "migrations/enable_uuid.rb", "db/migrate/enable_uuid.rb"


Seems to me like there should be an easy API endpoint about generating migrations. (I would've used the generator, but my migration doesn't fit the generator invocation, it's about enabling a DB extension)
Reply all
Reply to author
Forward
0 new messages