If you wanna use StatsD, but don’t want to bother setting up Graphite, here’s a simple chef recipe that installs both StatsD and Librato Metrics backend on Engine Yard Cloud.
Upgrade Rails Application to Ruby 1.9.3
Recently (and finally) we switched last app we had running on ruby 1.8.7 to ruby 1.9.3. As you can see, the impact on response time and apdex score is very nice :)


If for some reason you still have apps running on 1.8.7 dont delay anymore like we did, go ruby 1.9.3.
Overwriting “Rake Spec” Task
So you want to change the default behavior of rake spec task? You can do that using RakeTask#clear and RakeTask#enhance methods.
Example:
require 'rake'
require 'rspec/core/rake_task'
task :noop do; end
spec_prereq = Rails.configuration.generators.options[:rails][:orm] == :active_record ? "db:test:prepare" : :noop
namespace :spec do
RSpec::Core::RakeTask.new(:lite) do |t|
t.pattern = "spec/{models,presenters}/**/*_spec.rb"
end
RSpec::Core::RakeTask.new(:with_rails) do |t|
t.pattern = "spec/{controllers,integration}/**/*_spec.rb"
end
end
task(:spec).clear.enhance([spec_prereq, "spec:lite", "spec:with_rails"])
Adding Basic Authentication and Rewirite Rules to Your Engine Yard Application
Today I’ve decided to clean up and put some order in our Nginx setup and customizations for app hosted on AppCloud.
Till now we’re using keep files to add basic authentication for our staging and #{application}.rewites file for the rewrite rules. Turns out few things changed since last time I looked at these.
Tip (straight from the docs): Where possible, consider using an include file instead of a keep file.
Scoping Resources in ActiveAdmin
Here’s the use case I had yesterday.
We’re using ActiveAdmin in our current Rails 3 project. It’s really cool and gives you an easy way to jump start your admin section. Of course the more you want to customize, the more code you have to write. In our case we wanted to soft delete resource (lets say - a blog post). Actual marking of post as deleted is the easy part. You just need to customize the form:
# app/admin/blog_posts.rb form do |f| ... f.input :is_deleted, :label => 'Mark as deleted' ... end
Then you have to hide those posts, right? The easiest way was to use a default scope.
# app/models/blog_post.rb class BlogPost < ActiveRecord::Base default_scope where(:is_deleted => :false) end
Cool! But now all those “deleted” posts are hidden for admins too. Not cool…
Restart
Lets give this blog a try once again.
This time I’m going to use nanoc and nanoc3_blog. It looks like simple and easy solution, exactly what I actually need.
Stay tuned!