2010-05-20 00:00:00 +0000

Been neglecting this blog 'cause I've been busy.

Going to start reviewing what went down with my little app though.

2010-05-20 00:00:00 +0000

Backing up your DB on a Capistrano deployment

Yeah, it’s simple but useful. Since I’m using sqlite at the moment, it’s just a copy but you could run any command in a similar way. I’m also tagging the backup name with a date. Here’s a snip from my Capistrano deploy file….

2010-04-23 00:00:00 +0000

Capistrano deploy to multiple locations

Pretty simple, but wanted to log here so I can look this up in the future…

2010-04-05 00:00:00 +0000

I need to promote this more.

2010-04-04 00:00:00 +0000

Lost sleep over JSON and Rack::PostBodyContentTypeParser

I’ve been fighting this issue the last couple nights. I wrote earlier about how Rack::PostBodyContentTypeParser can automagically turn a posted JSON object into a Rack / Sinatra params hash. So, I wrote some tests to make sure this was the case and moved on. Well, it turns out in real life things weren’t working and I couldn’t figure out why. Everything looked cool, but the hash wasn’t getting set when I did an AJAX call in the browser - everything was empty. I looked at everything, from the server, to the JS library, to the browser, to setting different content types in prototype.js etc… UGH!

2010-04-04 00:00:00 +0000

Curl command to test JSON posts

curl -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"user":{"username_or_email":"username","password":"password"}}' http://fas/test_json_post

2010-04-01 00:00:00 +0000

Maybe I'll start embedding code from gist...

Let’s see how this looks…

2010-04-01 00:00:00 +0000

Couldn't get that last thing to work so keeping it simple (stupid)

This could undoubtedly be more elegant, but it’s late and I want it to work now. May take another stab at it later…

2010-03-31 00:00:00 +0000

Doing something different depending on file extension (MIME type) in Sinatra

This looks like a solution: sinatra-respond_to

2010-03-30 00:00:00 +0000

Using Rack middleware to parse JSON

In attempting to AJAX-ize the site, I had the desire to handle JSON as if it were form post data. Queue a Rack middleware solution. rack-contrib contains a bunch of common middleware extensions, one being the horribly named PostBodyContentTypeParser. To get this working I added: