On Apr 23, 2:45 pm, Erwin <[email protected]> wrote:
> giving a simple model, with a serialized Array attribute
>
> class Instructor < User
> ..
>   serialize :languages, Array
>
> I am looking in defining scopes like this :
>
> >scope speaking_english,   lambda { where("languages ... includes.... ?", 
> >:en) }
>
> which look for instructors in which the languages array include ":en"
>
> Is this kind of scope possible ?  or not.... ( just using query )
>
You probably can mash something together with a regular expression
(although it might be hard to cover all edge cases), but this sounds
to me like you shouldn't be using serialize, since it makes this sort
of stuff awkward (and slow, since you can't add indexes that will
support that sort of query). With a separate join table between users
and languages it all becomes very simple.

Fred



> thanks FYF  ( For Your Feedback)

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" 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/rubyonrails-talk?hl=en.

Reply via email to