Using helpers in model: how do I include helper dependencies?

I’m writing a model that handles user input from a text area. Following the advice from, I’m cleaning up the input in the model before saving to database, using the before_validate callback.

The relevant parts of my model look like this:

include ActionView::Helpers::SanitizeHelper

class Post < ActiveRecord::Base {
  before_validation :clean_input



  def clean_input
    self.input = sanitize(self.input, :tags => %w(b i u))

Needless to say, this doesn’t work. I get the following error when I try and save a new Post.

undefined method `white_list_sanitizer' for #<Class:0xdeadbeef>

Apparently, SanitizeHelper creates an instance of HTML::WhiteListSanitizer, but when I mix it into my model it can’t find HTML::WhiteListSanitizer. Why? What can I do about this to fix it?

Oracle 9i: Supposedly missing right parenthesis

I have a simple function written in Oracle 9i (version to simulate an in-line IF. For those interested, here’s the code:

create or replace
   (testExpression NUMBER,
    trueResult NUMBER,
    falseResult NUMBER)
      A simple in-line IF function for use with SQL queries. If the test
      expression evaluates to any non-zero value, it is considered to be 
      true, and the trueResult is returned. Otherwise, falseResult is
   IF (testExpression is null) or (testExpression = 0) THEN
      return falseResult;
      return trueResult;
   END IF;

This isn’t rocket science. Now, here’s the big mystery: if I execute the following SQL statements, everything is just fine, and works exactly as I expect:

SELECT IIF(1, 'true', 'false') FROM DUAL;
SELECT IIF(0, 'false', 'true') FROM DUAL;

However, the following generates a really bizarre error from Oracle:

SELECT IIF((0 = 1), 'false', 'true') FROM DUAL;

That error is as follows:

ORA-00907: missing right parenthesis.

Clearly, that isn’t the case. Would anyone happen to have an explanation for this little bit of bizarreness?

It’s taking a whole lot of self-control at the moment to restrain myself from hurling the Oracle server out the window. Oracle seems rife with these kinds of inanities.

EDIT: Is there some kind of magic syntax I have to use to use an equality operator in a select statement?