Memcache-client benchmarks

drbrain | Mon, 06 Mar 2006 22:15:00 GMT

Stefan Kaes writes about using memcached for Ruby on Rails session storage wherein he finds that memcache-client beats out all comers in his session store benchmarks:

memcache-client-1.0.3 provides much better performance: much faster than either the old implementation, pstore or ActiveRecordStore, but also faster than my optimized SQLSessionStore using MysqlSession.

Posted in ,

AWESOME

drbrain | Mon, 13 Feb 2006 02:31:00 GMT

Breaking Rails’ functional tests into controller tests and view tests will allow easy auditing between the two types of tests.

But first I need to move all the view assertions out of my functional tests.

Posted in ,

Don't touch my CDATA

drbrain | Mon, 21 Nov 2005 04:59:00 GMT

assert_tag parses CDATA

Posted in ,

DOS Vuln in Rails

drbrain | Tue, 01 Nov 2005 01:09:00 GMT

And I’m not telling you what it is, unless you’re named zenspider.

Posted in

Rails Functional TestCase

drbrain | Tue, 18 Oct 2005 07:26:00 GMT

Its a shame that Rails doesn’t define its own Test::Unit::TestCase subclasses. I’ve taken that into my own hands. This one puts Test on the front because that’s the Test::Unit way.

require 'test/unit'

def Object.path2class(klassname)
  klassname.split('::').inject(Object) { |k,n| k.const_get n }
end

class FunctionalTestCase < Test::Unit::TestCase

  def setup
    self.class.name =~ /\ATest(.*)\Z/
    return unless $1
    controller_klass = Object.path2class $1
    @controller = controller_klass.new
    controller_klass.send(:define_method, :rescue_action) { |e| raise e }
    @request = ActionController::TestRequest.new
    @response = ActionController::TestResponse.new

    @deliveries = []
    ActionMailer::Base.deliveries = @deliveries
  end

  def test_stupid
  end

end

Posted in , , ,

Easy model urls for Rails

drbrain | Tue, 18 Oct 2005 07:19:00 GMT

One part url params


class Player < ActiveRecord::Base

  def url_params
    return { :controller => 'players', :action => 'info', :id => username }
  end
    
end

One part url_for override

class ApplicationController < ActionController::Base

  def url_for(options, *params)
    if options.include? :model then
      options = options.delete(:model).url_params.merge options
    end

    return super(options, *params)
  end

end

[Simplified due to some insight from zenspider]

Then just add :model => AR_object to anything that accepts url params:

<ul>
<% @players.each do |player| -%>
<li><%= link_to player.username, :model => player %>
<% end -%>
</ul>

And ba-bam!

<ul>
<li><a href="/players/info/herbert">herbert</a>
<li><a href="/players/info/joseph">joseph</a>
</ul>

Posted in ,