Ez_where: Stuck Again

I just keep thinking this is going to slice through queries like a hot
knife
through butter, but… there’s something I’m not getting. Here’s the
gist:

get the people like the search criteria

Members.find(:all, :conditions => [‘first LIKE ? OR last LIKE ?’,
params[:search], params[:search])

joined with the alternative of member.comments.needs_followup <> 0 iff
there
is a params[:followup] and it is equal to 1.

Does this make sense?

Thanks

View this message in context:
http://www.nabble.com/ez_where%3A-Stuck-Again-tf2017867.html#a5548178
Sent from the RubyOnRails Users forum at Nabble.com.

On Jul 28, 2006, at 3:23 PM, s.ross wrote:

joined with the alternative of member.comments.needs_followup <> 0


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Hey-

I am not sure what you are trying to do there. Can you explain a bit

more? Or give the input and sql oputput you would expect?

-Ezra

What I wound up with was this (which works). I don’t know if it’s the
best
way:

def self.find_filtered(options_hash = {})
logger.debug “project = #{options_hash[:project]} and it returns
#{options_hash[:project] !~ /^–/}”
return self.find(:all, :order => ‘members.created_on DESC’, :limit
=>
20) unless options_hash[:search] || options_hash[:followup] ||
options_hash[:project] !~ /^–/
options_hash[:search] = “%#{options_hash[:search]}%”
cond = Caboose::EZ::Condition.new :members do
any {first =~ options_hash[:search]; last =~
options_hash[:search]}
end

if options_hash[:followup] == '1'
  cond1 = Caboose::EZ::Condition.new :members do
    follow_up == '1'
  end
  cond << cond1
end

if options_hash[:project] !~ /^--/
  cond2 = Caboose::EZ::Condition.new :members do
    projects =~ "%#{options_hash[:project]}%"
  end
  cond << cond2
end

conditions = cond.to_sql
@conditions = conditions
return self.find(:all, :order => 'members.created_on DESC', :include 

=>
:contacts, :limit => 20, :conditions => conditions)
end

Ezra Z.-3 wrote:

Hey-

I am not sure what you are trying to do there. Can you explain a bit
more? Or give the input and sql oputput you would expect?

-Ezra


View this message in context:
http://www.nabble.com/ez_where%3A-Stuck-Again-tf2017867.html#a5578519
Sent from the RubyOnRails Users forum at Nabble.com.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs