NOTE: This information is outdated, and most links are dead
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…
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
cd ~ mkdir -p .rails/generators rails temp cd temp script/plugin install acts_as_authenticated cd vendor/plugins/acts_as_authenticated/generators/ mv * ~/.rails/generators/ cd ~ 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.
# NOTE: these URLs no longer work, just kept here for posterity cd ~ mkdir -p .rails/generators cd .rails/generators svn co http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated/generators/authenticated/ authenticated svn co http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated/generators/authenticated_mailer/ authenticated_mailer 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!
# NOTE: these URLs no longer work, just kept here for posterity cd ~ mkdir -p .rails/generators cd .rails/generators echo "placeholder" > README svn import . https://url.to_your_svn_server.net/repos/somerepo/my_generators cd .. rm -rf generators svn co https://url.to_your_svn_server.net/repos/somerepo/my_generators generators cd generators svn propedit svn:externals . # this opens up your $EDITOR, add the following to it: authenticated http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated/generators/authenticated/ authenticated_mailer http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated/generators/authenticated_mailer/ authenticated_migration http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated/generators/authenticated_migration/ # save and exit svn ci -m "adding acts_as_authenticated" 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!
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 :)