Ruby on Rails :resources routed to different controller

A bit of background info: I’m busy porting Moo Invoicing to Rails as it’s just become too cumbersome to add features to and update in it’s current state. It’s written in CodeIgniter, but the time you save writing something in Rails as compared to your average PHP framework is more than noticeable.

Now, in Moo Invoicing you have invoices and quotes. They’re effectively the same thing, but with some minor differences (due date, payments, etc.) So, instead of having a heap of duplicate code, it makes sense to use the same controllers, models and views for both quotes and invoices. I did pretty much the same thing in CodeIgniter, but rails does much more magic in the background, so to hack it to do your bidding is usually a bad idea and can cause you to loose quite a few “features” the framework provides. Also, being new with Rails, you frequently come to times where you think that what you’re trying to do will be “too advanced” for the framework to handle, and you’ll need to do some actual coding, and more frequently you realize that you’re wrong. Most of the time, the Rails guys have a SUPER easy way out. This is one of those cases – it just wasn’t in any of the Rails guides. Continue reading