views:

25

answers:

4

I'm in the process of creating my first rails plugin and am finding managing version control of the plugin and testing app rather annoying.

Here's my problem:

To actually test my plugin in action I need to run it within a test application (which is basically just a scaffold app where I install the plugin)

When I'm making changes to the plugin, it's convenient for me to change it within the test application so i can immediately see the changes come through. However, when I want to commit and push my changes back to github I end up copying all the files out of the test app back into my "naked plugin" folder and doing my commits.

Is there a better way to manage this without copying files back and forth? I'm interested to hear from other plugin developers if possible on how you manage this situation.

One potential solution I've conceived of is to have another git repository within the vendor/plugins/myplugin directory (which will have the remote repo of github). Im not sure if this is best though (and so far I haven't been very successful in making it work...)

+1  A: 

I create a soft link in the vendor/plugin directory to point to the plugin source code. If you are on Windows you can use the junction tool to create a softlink. E.g:

c:\test_app
     vendor
       plugin
         foo_plugin -> points to c:\foo_plugin

c:\foo_plugin
  lib
KandadaBoggu
+2  A: 

I recommend to use git submodules, check a detailed description.

nathanvda
That's exactly what I was looking for, thanks!
Ganesh Shankar
+1  A: 

Submodules are going work best I think. What I don't like about developing plugins is that you're always starting/stopping the script/server. Without knowing what kind of plugin you're building, I'll just assume that you're building an abstracted class of some kind.

I personally think the best way to go is to develop the class in the lib directory of your rails app. Once you get it about 99% done, then move the class into the lib directory of your plugin. Then commit the changes to the plugin repo.

Bryce
+1  A: 

If you're willing to package your final plugin as a gem, then there is a much easier way. In your basic scaffold app, inside your Gemfile you can point to a local path:

gem 'foo', :path => "../foo"

This way your scaffold app and engine/plugin are in two separate directories; two completely unrelated git repos. You don't even have to start & stop your scaffold web server when you make changes to the plugin (at least in rails 3).

I just wrote up a tutorial for how I created my first rails engine and I extracted the foundation into a good starting point for other engine builders:

http://keithschacht.com/creating-a-rails-3-engine-plugin-gem

As an end user of a plugin, I think it's much easier if it's packaged as a gem. Not only is more functionality possible with a gem, developers can install it once and use it in many apps, dependencies can be easily handled, upgrades are as simple as changing a version number, and you don't have to store the entire plugin in your main app's repo.

Keith Schacht
Cool thanks, I'll give it a go! Making my plugin into a gem has been on my list of to-dos for a little while...
Ganesh Shankar