Forum: Ruby on Rails returned values and consequent usage

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Craig W. (Guest)
on 2006-01-29 09:42
(Received via mailing list)
I think I can have finally reduced my problem to something somebody can
help me with.

I am using auto_complete...

specifically the form command is...

<%= text_area_auto_complete_for :case_manager :name %>

I need to use the value derived here in my controller...

If I use...

cm = CaseManager.find(:first, :conditions => "name = 'Thomas E Dewey'")

it works. I need to substitute the value derived from auto_complete
above for Thomas E Dewey...

cm = CaseManager.find(:first, :conditions => "name = name")
the lookup will always return record #1

cm = CaseManager.find(:first, :conditions => "name = :name")
cm = CaseManager.find(:first, :conditions => "name = @name")
cm = CaseManager.find(:first, :conditions => "name = case_manager_name")
all give me errors syntax or operator or run-time errors

How do I get the value derived from auto_complete into a find command?

Craig
Bob S. (Guest)
on 2006-01-29 11:09
(Received via mailing list)
Are you referring to when it sends it back to the server via a form
post?

Not sure exactly what you want but try:

CaseManager.find(:first, :conditions => ["name = ?", case_manager.name])

You can always fall back to the params:

CaseManager.find(:first, :conditions => ["name = ?",
params[case_manager][name]])

Again, not sure where you are trying to "find" something using the value
of
the auto_complete field. Or are you trying to use this to populate the
auto_complete field?


Bob S.
http://www.railtie.net/
This topic is locked and can not be replied to.