Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion How to define a WHERE condition on an association
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
gmoniey  
View profile  
 More options Nov 13 2012, 6:11 pm
From: gmoniey <gmon...@gmail.com>
Date: Tue, 13 Nov 2012 15:11:42 -0800 (PST)
Local: Tues, Nov 13 2012 6:11 pm
Subject: How to define a WHERE condition on an association

Hi,

I have a simple define index, and I want to limit the indexed records to
those that have an association on a nullable field. Here is what my
define_index block looks like:

  define_index do
    indexes :name, :sortable => true

    has :format_id, :created_at
    has assoc(:format).name, :as => :format_name

    where "my_table.deleted = 0 AND (format_id IS NULL OR format_name LIKE
'Indexable Format Name%')"

    set_property :delta => :delayed
  end

The error that I get when indexing is: Unknown column 'format_name'. I was
wondering if the above is even possible?

Also, just wanted to double check that my assoc has line is correct? Seems
like 'format' is a reserved keyword.

Thanks.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.