Hey Sonia;

You wont be able to get a 'where category = "red"' out of that.

Back in the bad old days (read 1998) we used to do that by wrapping each 
category in [], so you'd have '[red][green]' then you'd say where category like 
'%[red]%'

You should probably index that field if you go that way, not sure an index is 
even used on a like '% ... %' 

Matta

On 12/08/2011, at 10:57 AM, Sonia Hamilton wrote:

> A question about ActiveRecord and denormalisation - I'm wondering if
> there's a clean way to do it or plugin that supports it.
> 
> A bit more detail...
> 
> I've got a table hosts, where category is denormalised:
> 
> hostname    ipaddr      category
> fred        1.2.3.4     red;green
> mars        2.3.4.5     red;blue;disabled
> chikaboom   3.4.5.6     orange
> 
> Via ActiveRecord I'd like to produce queries like
> 
> "select * from hosts where category = 'red';"
> 
> Any pointers?
> 
> Also, I'm not using ActiveRecord from within Rails - I'm using it as a
> ORM within my prog.
> 
> (Yes I 'should' have a 1-many relationship between hosts and a category
> table; but I don't want to produce a plethora of small lookup tables)
> 
> --
> Sonia Hamilton
> http://soniahamilton.wordpress.com
> http://www.linkedin.com/in/soniahamilton
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby or Rails Oceania" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/rails-oceania?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to