Thursday, May 29, 2008

The blog is moving...

I'm moving the blog to rubyblocks.se. Please update your bookmarks and subscriptions.

Thursday, May 22, 2008

make_resourceful and odd controller names

I've been debugging make_resourceful to try to figure out why it fails to generate an index action for a controller named NewsController. After a couple of hours I found the now slightly obvious reason in lib/resourceful/default/accessors.rb...

The singular? method returns true for "News".

A simple solution would be to define singular? in your controller and let it return false.

Example:

class NewsController < ApplicationController
def singular?; false end

make_resourceful do
actions :all
end
end


See also: More on odd controller names

Tuesday, May 20, 2008

response.should have_tag problems

I use "integrate_views" to combine controller and view specs. The thing I discovered just now is that if you have nested describes, you have to place "integrate_views" inside the inner describe or "have_tag" won't work.

The error you typically get otherwise (even when the element exists) is:
Expected at least 1 element matching "div#content", found 0.

For this particular project I'm using RSpec 1.1.3.