I have recently completed my first rails app (yay!), and now I'm starting my second one. I'm also starting to realise that I can simply re-use a lot of the code I've written for the first app. But what's the best way to do that. Right now I just copy e.g. the LoginController from my first app and paste it into my second app. That's silly, isn't it? Because it breaks with Rails' DRY principle. What do you say?
My first app was a simple e-commerce site, with a custom-made CMS behind the scenes: UKAutobarn.com. I have only partly adjusted it for IE6, so it's best viewed in Mozilla or Safari.
I think I won't re-use any components from my first app in my second one, because it might get too complex in the end and does not allow for too much customisation. I will re-use the stylesheet for the CMS from app 1 though...
I thought Engines were a very good idea when they first came out. Then I started using them, and, well, I don't use them anymore
The best thing to do is refactor your code out into a plugin. Any time you'll be reusing or duplicating code it's probably a good candidate for a plugin. App-specific code is usually a bit grittier...but fortunately there's been some recent discussion in the Rails community about this sort of thing. Okay not really discussion, but more like a couple guys telling everyone how they solved the problem Check out http://www.pluginaweek.org which is a new blog where these guys talk about a bunch of plugins they wrote. One of them that will come in handy for you is the just-announced appable_plugins, which lets you share model, helper, and controller code through apps. It solves my two key gripes with Engines: Engines can't share model code easily, and Engines are just pretty heavy over all.
I'm excited about that blog, I think we'll get lots of cool stuff from them in the coming months.