0

I'm writing a Rails 3 plugin that uses another Rails 3 plugin that I recently wrote. Let's call them July and August. So in August's gemspec, I add the line:

s.add_dependency "july", "~> 0.0.1"

and I run bundle install. Then I create some models and fixtures. Next I need to migrate the database:

$ cd test/dummy
$ rake august:install:migrations
$ rake db:migrate

Now, the August (the plugin I am creating) tables are in the development and test databases, but the July tables are not. But my August tables have foreign keys to my July tables, so before I can run any tests, I need to create the July tables and write appropriate fixtures. I would expect to run rake -T and see

rake august:install:migrations
rake july:install:migrations

but all I see is the august rake task. So how do I create the July database tables (other than creating a new migration, which would violate DRY since I've already done that in my July codebase)?

Isaac Betesh
  • 2,935
  • 28
  • 37

1 Answers1

0

The Dummy App has to be directly dependent on "july" for it to load "july"'s rake tasks. So I need to include it in the Gemfile, not the gempspec. However, putting it in Gemfile won't force real (non-dummy) apps to install july when I bundle install after putting "august" in their Gemfile/gemspec.

So I need to include it in both places--in the Gemfile for the rake task (and this can be in a :development group), and in the gemspec (using add_dependency or add_runtime_dependency) to force installation of the dependency. That's the solution, but I don't understand why.

I tried explaining my thoughts on this in my comment here but wasn't really able to pinpoint any logic that explains this design methodology. Could someone please explain the true reason?

Community
  • 1
  • 1
Isaac Betesh
  • 2,935
  • 28
  • 37