We have a large Rails site live which runs with production level logging. Occasionally there is a problem where debug-level logs would help us track down a problem quickly, but we can’t restart one of the Rails servers to have logs put in debug mode for a single request (and don’t want to run in debug mode for long as the servers are heavily used).
For our purposes it would be nice to have just the log output for the single request we want to look at. Rails’ console and the app object to the rescue!
Having just launched a major Ruby on Rails site, there has been a period during which we’ve had to improve performance dramatically. While most of the benefits have been had by using a custom Rails middleware class there have been a number of actions that aren’t cacheable so I’ve needed to profile the request and then optimise some internals.
Fortunately starting with Leopard, Apple has included a patched version of Ruby that has DTrace probes support.
There are times when Rails feels very heavy! Jason Seifer has joked for ages about how Rails can’t scale, and we all know that’s a fallacy, but there are times when you know a bit of code is simple and could be really lightweight but having it as part of a controller, having gone through the Rails routing process and all the filters would just slow it down.
At the end of 2008 Rail Metal was introduced and it came like a breath of fresh air. It simply works as a lightweight class dropped in to /app/metal/ that is given the opportunity to handle a request before the main Rails stack.
When I first started reading about Rails Metal/Middleware it seemed like a great idea, but it didn’t really offer anything with a real tangible benefit. Can it be used in real life, or is it a nice bit of icing – something fancy to show off to non-Rails/Rack developers?
You may be familiar with Sau Sheong Chang's blog at blog.saush.com and if not I'd recommend checking it out (after reading this blog post of course). Sau Sheong is an expert at describing how to create common web systems with very minimal Ruby code - see his blog posts on Clone TinyURL in 40 lines of Ruby code and Write an Internet search engine with 200 lines of Ruby code for more examples of what I'm talking about.
I actually found his book Ruby on Rails Web Mashup Projects on Amazon after reading his blog and snapped it up immediately, hoping it was just as good as his blog.
On a typical modern website, most pages are dynamically generated from various database tables. There is normally the main content area which contains content such as the latest news stories. Then there are usually various boxes in a side bar such as the latest pictures from the galleries which contains the latest content in various other tables. How those boxes are developed differs in best practices between Rails and Symfony...
After building my personal site from scratch in Symfony/PHP5 - I decided as I am leaning towards Rails now it was time to rewrite it in Rails. I had some good experiences during the process and overall I'm pleased with it. This may serve as a useful push if you're currently a PHP developer tempted by Rails.
As a contractor it is always wise to stay on top of upcoming technologies, today's niche market may be tomorrow's big earner. This year I decided to learn Ruby on Rails, so I thought I'd write a post on why I think Rails is such as excellent development system.