Wolfmans Howlings

A programmers Blog about Programming solutions and a few other issues

How to setup SyntaxHighlighter in Rails 3.1.1

Posted by Jim Morris on Sat Nov 12 01:36:29 -0800 2011

Or how to get Rails 3.1.1 assets in vendor/assets to work in production.

... Show more ...

Posted in Rails  |  Tags rails,syntaxhighlighter,assets  |  2 comments

Turn off forgery protection when using caching

Posted by Jim Morris on Sat Dec 18 01:04:06 -0800 2010

This one does not seem to be documented, and I just got bit.

After porting my blog engine to Rails 3, I noticed that after a while comments were being rejected with an ActionController::InvalidAuthenticityToken error.

... Show more ...

Posted in Rails  |  Tags rails,authenticity  |  4 comments

Upgrading a Rails 2.2.2 app to Rails 3

Posted by Jim Morris on Fri Dec 17 15:27:17 -0800 2010

After porting my blog engine from Merb to Rails3 code here I thought I'd upgrade my Snow Dogs R Us Site (aka dogz.us) to Rails 3.

It was written in Rails 2.2.2 so I figured it would not be too hard, well it was easier to port my Merb App than it was my Rails app!

... Show more ...

Posted in Rails  |  Tags upgrade,rails3  |  3 comments

A Simple Challenge Response authentication scheme for Rails3

Posted by Jim Morris on Mon Nov 29 23:06:41 -0800 2010

UPDATE the following is for pre rails 3.1, there is an addendum at the end for rails 3.1+

I have ported my blog engine (that hosts this site), from Merb to Rails 3. You would expect it to be fairly simple as Rails 3 is meant to be the next version of Merb.

... Show more ...

Posted in Rails  |  Tags authentication,javascript  |  no comments

Fixtures VS Factories, or how I do fixtures

Posted by Jim Morris on Fri Feb 06 15:04:54 -0800 2009

There is a raging debate in many forums about how to do fixture-like things. Basically how do you populate a database with test data so you can run your Specs/Tests/Features.

There are several libraries out there to do this like FactoryGirl, FixtureReplacement, Machinist, Fixjour etc etc. If you use Rails and ActiveRecord pick the one you like and be happy ;)

... Show more ...

Posted in Rails,Merb,Sequel  |  Tags merb,sequel,fixtures  |  1 comments

XPath matchers for rspec

Posted by Jim Morris on Wed Jan 02 13:32:50 -0800 2008

I've been working on a project that is mostly Java for the last many months, so haven't had much Ruby or Rails stuff to share.

However one thing I found when working on my tests in Java was an xpath matcher for JUnit 4.0 using the Hamcrest libraries.

... Show more ...

Posted in Rails,RSpec  |  Tags rspec,xpath,matcher  |  5 comments

Bit Vector Preferences

Posted by Jim Morris on Tue Aug 07 23:53:09 -0700 2007

In my latest web project I potentially have a lot of boolean preferences, which I use for enabling or disabling various email notifications to users.

Rather than having to add a migration everytime I want to add a new preference, I thought I would use the composed_of feature in my model and compose the boolean preferences from a bitvector. That way I can simply modify my model to add new preferences rather than add new columns to the database.

... Show more ...

Posted in Rails  |  Tags rails,preferences,composed_of,bitvector  |  2 comments

Paginating acts_as_taggable with will_paginate

Posted by Jim Morris on Mon Jul 30 15:04:50 -0700 2007

A question I see asked a lot is how do I paginate acts_as_taggable (on steroids)?

I haven't seen any answers I liked, so I created my own, which I'm sure a few people won't like either ;) But it works for me (tm).

... Show more ...

Posted in Rails  |  Tags acts_as_taggable,will_paginate  |  20 comments

RSpec testing all actions of a controller

Posted by Jim Morris on Sat Jul 28 14:23:07 -0700 2007

A pattern I find very helpful is to find all the actions in a controller and apply a test to all those actions.

For instance this is useful for automatically testing all actions are protected from unauthorized access when using a login system.

... Show more ...

Posted in Rails,RSpec  |  Tags rails,rspec,controllers  |  14 comments

Using RSpec to test HAML helpers

Posted by Jim Morris on Sat Jul 14 16:44:33 -0700 2007

UPDATED for HAML 2.0 and RSpec 1.1.5 - Changed open to haml_tag, prefix helper. to all rspec calls...

The most recent release of HAML introduced a neat feature that allows you to use HAML-like syntax in your helpers to generate HTML HAML#haml_tag.

... Show more ...

Posted in HAML,Rails,RSpec  |  Tags test,haml,rspec,helpers  |  9 comments