Ask for Help
“How do I stop bit.ly from adding trailing slashes to my URLs?”
If you have a url of the form http://maps.google.com?q=37.7,+-122.4 then bit.ly will normalize it by adding a trailing slash: http://maps.google.com?q=37.7,+-122.4/. However, the work around is to instead correctly insert the slash yourself: http://maps.google.com/?q=37.7,+-122.4
“Mongrel is raising undefined constant exceptions. How do we stop this or workaround it?”
A non-threaded Rails 2.1 application using Pivotal Labs’ Desert Plugin gets occasional NameError exceptions about undefined constants that should have been loaded by Rails / Desert. The application preloads all dependencies and the errors don’t occur until there is a request; it’s not the same NameError every time.
No one had seen this behavior and so the main suggestion was to upgrade Rails. A work around to make monit reload the Mongrel process is to have Mongrel exit on NameError exceptions by calling Process.exit in a rescue_from block.
Hey Matthew! Great to see that you are still working with Rails! How are ya?
October 27, 2009 at 12:40 pm
Some more hints about using the bit.ly API:
- The API responds with JSON, but the Content-Type is “text/html” instead of “application/json”. Some HTTP libraries automatically parse JSON into an object graph, but may not do it if the Content-Type is not “application/json”. So you might have to force your HTTP library to parse the JSON or do it manually.
- The API responds to “/shorten” with a JSON string that contains a map from the long URL(s) you passed in to the shortened versions. If you don’t properly escape the long URLs that you pass in, then bit.ly will do it for you and the keys in the returned map won’t be exactly the URLs you passed in, which makes finding the shortened URLs hard. So be sure to properly escape the URLs.
October 28, 2009 at 1:28 pm