Hiding ruby gem 'is deprecated with no replacement' messages
I recently installed ruby 1.9.2 via rvm, and suddenly every command started spitting out hundreds of line of deprecation messages : ...
I recently installed ruby 1.9.2 via rvm, and suddenly every command started spitting out hundreds of line of deprecation messages : ...
I’ve been flat out with a couple of contracting projects recently - apologies for the four-month blogging hiatus! One of these projects (albeit a quickie) was a weekend spent making a rails site for a couple of New Zealand organizations to help the victims of the Japanese quakes and tsunami relocate themselves and/or their children to New Zealand temporarily. ...
I was playing around on the weekend screen-scraping and analyzing word-frequencies for various sites (don’t ask), and was getting some slow responses (and accidentally got my IP blocked from one site when I hit them a few too many times). Eventually I hit upon the idea of hitting Google Cache for each URL (the pages I was scraping had sequential ?id=xxx URLs so it was easy to automate), with the aim of speeding things up a bit and taking some load off the target sites. With this in mind, I spent a few hours Saturday and Sunday developing fromthecache.com - it’s built on rails, and designed to provide transparent access to the Google cache, while fetching the original page as a fallback if necessary. ...
2013-03-28 Update : This project is very dated, and I don’t recommend it’s use. It’s now hosted on GitHub. I’m happy to announce the release of Rails Kitchen Sink a rails-project-starter, which I’ll be building all future Rails apps off of. ...
Rails has a very handy ‘respond_to’ feature to render your pages in different formats : respond_to do |format| format.json { render :json => @user } format.xml { render :xml => @user } format.html end However, by default it outputs every field in the model, which exposes some data (encrypted-password and password-salt) that I’d rather keep to myself : ...
I’ve been playing about with Devise and CanCan for rails authentication and authorization recently - this great pair of posts from Tony Amoyal have helped a great deal. I have a User model and a Role model, and wanted to automatically add the :user role to each user whenever roles are assigned. The roles were set in the controller as follows: ...
If you are getting an error about ‘undefined method assert_valid_keys’ in Rails : undefined method `assert_valid_keys' for :time_entry_product:Symbol … it may be because you have two relationships specified on the same line in your model : ...
After upgrading a few gems recently, I found that the content returned from the nginx memcached_pass directive always had a few strange characters prepended. After some investigation it seems that this is caused by rails ‘marshalling’ the data. If you’re using a memcached set command such as Cache.set(key, content, time_to_live) You need to add an extra argument to force rails to cache the raw data instead of marshalling it : ...
I’ve been wondering for a while why Phusion Passenger seems to completely ignore the PassengerMaxPoolSize, PassengerMaxInstancesPerApp and PassengerPoolIdleTime directives. I recently discovered that they don’t work inside VirtualHost blocks in apache config. The old (non-working) config was something like : ...
This plugin is very similar to the built-in Rails ‘caches_page’ functionality, except it caches to memcached rather than a file. It relies on the ‘memcached_pass’ nginx directive to serve pages directly from memory if possible, and only passes to rails if necessary. On my server I’ve seen a 75% reduction in Ruby memory usage using this technique. ...