How can a gem (unintentionally) change the migrations path?

7 views
Skip to first unread message

Andy Jeffries

unread,
Apr 13, 2016, 9:19:13 AM4/13/16
to rubyonra...@googlegroups.com
I wrote a Gem (https://github.com/absolutedevops/civo) which is a simple Rails Engine containing a few API accessing models.

However, when I include it in a Rails project, any generators create their files under the Gem's source code not the project's. I can't see anything I'm doing in the Gem that would cause this. It's repeatable (it's happening in two projects at my company and I can reproduce it with a minimal set of steps below).

Can anyone tell me how I've managed this? I've been a Rails user for many years but haven't ever come across this before, nor has a skim through the Rails code given me any indication of how I'd change the migrations path if I wanted to!

Thanks,


Andy



Reproducible steps:

$ rails -v
Rails 4.2.6
$ rails new civo-test
[...]
Bundle complete! 12 Gemfile dependencies, 55 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
         run  bundle exec spring binstub --all
* bin/rake: spring inserted
* bin/rails: spring inserted
$ cd civo-test
$ echo 'gem "civo"' >> Gemfile
$ bundle
[...]
Bundle complete! 13 Gemfile dependencies, 66 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
$ rails g migration a_new_migration_here
Running via Spring preloader in process 75091
      invoke  active_record
      create    db/migrate/20160411093346_a_new_migration_here.rb
$ ls -l db/migrate/20160411093346_a_new_migration_here.rb
ls: db/migrate/20160411093346_a_new_migration_here.rb: No such file or directory
$ rails g migration a_new_migration_here                 
Running via Spring preloader in process 75193
      invoke  active_record
   identical    db/migrate/20160411093346_a_new_migration_here.rb
$ ls -l /Users/andy/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/civo-0.3.21/db/migrate/ 
total 8
-rw-r--r--  1 andy  staff  73 11 Apr 10:33 20160411093346_a_new_migration_here.rb
Reply all
Reply to author
Forward
0 new messages