April 17th, 2011 | Published in ruby
I’ve been fiddling around with the idea of building an app that would help me keep track of client sites: What plugins they have installed, what version their core software is at, what needs to be added to them, etc. It’s the kind of thing you could keep in a spreadsheet, but as I’ve sketched out what I want to keep track of, it’s gotten more and more unwieldy. I’d like, for instance, to keep track of which version WordPress is at in one place by updating just my WordPress entry, then list all the sites and get some quick visual feedback on which ones need an update. Same with plugin versions, template versions, etc.
It’d also be nice to have on place to keep track of which hosts each site lives on, what the path to the site files on the server is, client contact info, client support/development rates, and a worklog for each site (the better to have invoicing at some point).
Padrino’s cool because it provides a way to generate an admin interface that’s a step beyond Rails’ basic scaffolding. It’s nothing you couldn’t do in Rails pretty quickly, but Padrino makes it pretty and simple. For instance, here’s how to generate a Site model for my app:
g model site name:string url:string client_id:integer cms_package_id:integer server:string path:string
And here’s how to quickly create an admin panel to manage sites:
padrino g admin_page site
Then you just load up
/admin/sites, enter your user name and password, and you have a password-protected Web admin interface from which you can create and edit sites:
It doesn’t figure out associations, so you have to hand-edit here and there to do stuff like create a select item to pick which of your clients a site belongs to. You can do that by defining a collection in the controller (e.g. “clients”) and then use that collection with a form helper:
And that gets you this:
Combined with Pow and an hour of poking around the docs to figure out how to make the helpers work, Padrino gave me a working site manager app in under an hour. Nice.