NOTE: This information is outdated, and most links are dead

While acts_as_authenticated installs as a plugin, it really is a generator. This means that you script/plugin install it, run the generator, and then have no further use for the plugin in that app. Now this seemed a bit silly to me. Not that I question Rick’s choice to make AAA a plugin, it is the easiest way of distributing the code, and the least hassle for the user. But I now use AAA for all app’s that need authentication, so I have to install; generate; delete AAA every time…

But wait, acts_as_authenticated IS a generator! (Or rather, 3 generators) So why not install it as a generator? This is exactly what I did, and here is how i did it:

Installing AAA as a generator, the lazy way

  1. cd ~
  2. mkdir -p .rails/generators
  3. rails temp
  4. cd temp
  5. script/plugin install acts_as_authenticated
  6. cd vendor/plugins/acts_as_authenticated/generators/
  7. mv * ~/.rails/generators/
  8. cd ~
  9. rm -rf temp

That’s it! You now have acts_as_authenticated installed as a generator for all your apps. This is not very elegant, obviously, and not easy to maintain. So lets try it again, this time slightly more elegant.

Installing AAA as a generator, the subversion way

Right, lets do that again, this time using subversion directly.

  1. # NOTE: these URLs no longer work, just kept here for posterity
  2. cd ~
  3. mkdir -p .rails/generators
  4. cd .rails/generators
  5. svn co http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated/generators/authenticated/ authenticated
  6. svn co http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated/generators/authenticated_mailer/ authenticated_mailer
  7. svn co http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated/generators/authenticated_migration/ authenticated_migration

There we go. We now have acts_as_authenticated installed, and it’s version controlled.

You can install all svn controlled generators this way. So here lies the next part! After a while, you might have dozens of generators installed, and you’ll need to cd <generator name>; svn up each and every one separately to keep them up to date.

Installing AAA as a generator, the svn:externals way

Let’s exploit our own subversion server, and svn:externals to get them all in one go!

  1. # NOTE: these URLs no longer work, just kept here for posterity
  2. cd ~
  3. mkdir -p .rails/generators
  4. cd .rails/generators
  5. echo "placeholder" > README
  6. svn import . https://url.to_your_svn_server.net/repos/somerepo/my_generators
  7. cd ..
  8. rm -rf generators
  9. svn co https://url.to_your_svn_server.net/repos/somerepo/my_generators generators
  10. cd generators
  11. svn propedit svn:externals .
  12. # this opens up your $EDITOR, add the following to it:
  13. authenticated http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated/generators/authenticated/
  14. authenticated_mailer http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated/generators/authenticated_mailer/
  15. authenticated_migration http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated/generators/authenticated_migration/
  16. # save and exit
  17. svn ci -m "adding acts_as_authenticated"
  18. svn up

And we are done! No matter how many generators you add this way, all you need to do now is cd ~/.rails/generators;svn up, and all your generators are updated!

Windows…

All this is for *nix (OSX, linux, solaris, … any unix like os.), but what about windows? Honestly, I don’t know… I don’t use windows much myself, so if anyone figures out how to get this working on windows, please feel free to contact me with the details, and I will append it here.

EDIT: james2m on #mephisto @ irc.freenode.net noted the windows place to put this is C:\Documents and Settings\username\.rails\generators

In closing, I hope this will be useful to someone. I know it saved me quite some work, and it just feels … “cleaner” somehow :)