Google Groups Home
Help | Sign in
that find_by_name_fragment method we were working on...
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all
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
Roy Pardee  
View profile
 More options Apr 27, 12:05 am
From: "Roy Pardee" <rpar...@gmail.com>
Date: Sat, 26 Apr 2008 21:05:54 -0700
Local: Sun, Apr 27 2008 12:05 am
Subject: that find_by_name_fragment method we were working on...

For the record--this works, and I think is railsish enough for you guys to
not make fun of me. ;-)

  def self.find_by_name_fragment(frag, proj = nil)
    # Got to add in the wildcard where we need it.
      frag += '%'
      # Look for people whose first or last names begin with the fragment.
    cond = "(first_name LIKE :frag OR last_name LIKE :frag)"
    unless proj.nil?
      # We know what project we're looking for new people on--remove anybody
already assigned to that project.
      cond += " AND id not in (select person_id from project_people where id
= :proj)"
    end
    # AR knows to ignore the proj named parameter if it doesn't appear in
the crition string.
      options = {:conditions => [cond, {:frag => frag, :proj => proj}]}
      Person.find(:all, options)
  end


    Reply to author    Forward  
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.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google