Quantcast
Channel: Software As She's Developed » Rails | Software As She's Developed
Browsing index pages (18 articles)
↧

Speeding up Rails tests with Spring

I found Rails tests were running slow, these things helped. Instrumenting application.rb First, I added some logging to application.rb ruby < view plain text > def logg(m)   puts "#{DateTime.now}...

View Article


Image may be NSFW.
Clik here to view.

How to use different favicons for development, staging, and production

It’s useful to have different favicons for each environment during development, as Pamela recently pointed out. Here’s how I do it. First, generate the images. Most graphics editor have some kind of...

View Article


Image may be NSFW.
Clik here to view.

Load-balancing Rails with Nginx

Well this was some fine undocumented black magic. I’ve got Player FM behind a load balancer now, using the following Nginx config. I’ll explain some more about the overall upgrade later. # App load...

View Article

Image may be NSFW.
Clik here to view.

Logging an error with Exceptional

Here’s a quick utility for people using Exceptional to track errors. It lets you force an exception to be logged and without having to rescue it. Example: exceptional “read_file”, “file not found” The...

View Article

Image may be NSFW.
Clik here to view.

Defer and Recur with Rails, Redis, and Resque

I’ve put off some scaling related issues about as long as possible, and am now proceeding to introduce a deferred-job stack. I’ll explain what I’ve learned so far, and with the caveat: this isn’t in...

View Article


Image may be NSFW.
Clik here to view.

Testing HTTPS Locally

As I’m migrating the player over to HTTPS, one challenge is partial content, leading to an incomplete padlock and strikethrough domain warning like this: And the harsh but fair warning, upon...

View Article

Image may be NSFW.
Clik here to view.

Monkey-patching a sample() method in Rails

It’s useful while debugging to choose a random sample. Thus you can include something like this in application.rb or an initializer. Now you can say Post.sample to get a single post or Post.sample(5)...

View Article

Image may be NSFW.
Clik here to view.

Private resources with ElasticSearch and Tire

I’m adding private channels to Player FM and one consideration is search results. Tire’s activerecord does a great job at making updates transparent, but in this case some manual overriding is...

View Article


Image may be NSFW.
Clik here to view.

Rails Cache Sweeper Gotchas

As you’ll see here, Rails cache sweepers are a tricky subject. Here are some general things I’ve learned. Sweepers are dual creatures. “Here’s the scoop: sweepers observe both your models and your...

View Article


Image may be NSFW.
Clik here to view.

Firefighting an RSS Aggregator’s Performance

That’s a before-and-after shot of the database server’s CPU! I was watching it slowly creep up, planning to inspect it after some other work, before receiving mails from Linode that the virtual server...

View Article

Image may be NSFW.
Clik here to view.

Sorting a Rails log file by SQL duration

Rails’ ActiveRecord logger writes log files like: Post Load (735.8ms) SELECT posts.* FROM posts where post.title = 'foo' You may want to know the longest SQL queries for performance optimsation...

View Article

Image may be NSFW.
Clik here to view.

The Weirdness of Ajax Redirects: Some Workarounds

I've been dealing with the situation when your server redirects after a DELETE. Which is actually a fairly common use case. User deletes a blog post, redirect them to the index of all posts. The...

View Article

Image may be NSFW.
Clik here to view.

Rails Default Date Gotcha

This had me going for a while! I wanted to default a field to the epoch, i.e. some decades ago, or older. That's because a batch process will work on the records with the oldest such field, so setting...

View Article


Image may be NSFW.
Clik here to view.

Preventing a Rails (Mongrel App) from Crashing

I've had a Rails website which works fine for about 12-18 hours, then starts giving out intermittent 500 errors because the mongrels die. After searching around, I ended up fixing it on two levels....

View Article

Image may be NSFW.
Clik here to view.

Rails JSON, JSON Rails

< p style="clear:both; margin-top: 2em; "> Man, JSON has come out of nowhere! I first came across it amid the Javascript hype in early '05, now it's everywhere. Not only in your Ajax apps, but...

View Article


Image may be NSFW.
Clik here to view.

Ruby/Rails: Overriding NilClass

Rails uses "whiny nil", which means if you call a method on an object that happens to be nil (null), you get an exception. This is good. But with strings in a web app (in any language), you often don't...

View Article

Image may be NSFW.
Clik here to view.

If HTML Used Convention Over Configuration …

Browsers would automatically pull in CSS and JS according to the filename and I would no longer have to look for an example every time I need a link or script tag. In the absence of any other spec,...

View Article


Image may be NSFW.
Clik here to view.

Ruby is Rails is … REST

Will the peripheral IT community come to view REST and Rails as equivalent? It might sound ridiculous, but consider: Unix==Linux, Wiki==Wikipedia, Ajax=Web 2.0, blogging==RSS, podcast==spoken MP3. Last...

View Article
Browsing index pages (18 articles)


Latest Images