# Prompting user to enter value to feed Find

**URL:** <https://www.ruby-forum.com/t/prompting-user-to-enter-value-to-feed-find/95334>\
**Category:** Rails\
**Created:** [May 29, 2006, 7:37am UTC](https://www.ruby-forum.com/t/prompting-user-to-enter-value-to-feed-find/95334 "2006-05-29T07:37:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kublai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a3d4f5/32.png) [@kublai](https://www.ruby-forum.com/u/kublai)\
**Post date:** [May 29, 2006, 7:37am UTC](https://www.ruby-forum.com/t/prompting-user-to-enter-value-to-feed-find/95334/1 "2006-05-29T07:37:25Z")

</div>

Hi,  
While viewing part of a long list of records, the user may want to do a  
Find of a specific record (for example, find\_by\_name). The found record  
is then displayed using the list view. I’ve searched the wiki and  
couldn’t find a sample or information that will help directly in  
implementing this function. Any pointers?  
Thanks!  
gk

---

<div class="post-metadata">

**Author:** ![kublai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a3d4f5/32.png) [@kublai](https://www.ruby-forum.com/u/kublai)\
**Post date:** [May 29, 2006, 9:13am UTC](https://www.ruby-forum.com/t/prompting-user-to-enter-value-to-feed-find/95334/2 "2006-05-29T09:13:39Z")

</div>

Gene K. wrote:

> Hi,  
> While viewing part of a long list of records, the user may want to do a  
> Find of a specific record (for example, find\_by\_name). The found record  
> is then displayed using the list view. I’ve searched the wiki and  
> couldn’t find a sample or information that will help directly in  
> implementing this function. Any pointers?  
> Thanks!  
> gk

Could you pass the name through the query string, and if that string is  
present just overwrite the value  
in the list @ variable with a find(:all, :conditions =\> [“name =  
?”,params[:name]])?

–  
Matthew Wastrodowski  
Web D.  
[http://blog.familopia.com](http://blog.familopia.com)

removed\_email\_address@domain.invalid  
949 395-7215

---

<div class="post-metadata">

**Author:** ![kublai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a3d4f5/32.png) [@kublai](https://www.ruby-forum.com/u/kublai)\
**Post date:** [May 29, 2006, 2:41pm UTC](https://www.ruby-forum.com/t/prompting-user-to-enter-value-to-feed-find/95334/3 "2006-05-29T14:41:25Z")

</div>

Hi,  
While viewing part of a long list of records, the user may want to do a  
Find of a specific record (for example, find\_by\_name). The found record  
is then displayed using the list view. I’ve searched the wiki and  
couldn’t find a sample or information that will help directly in  
implementing this function. Any pointers?  
Thanks!  
gk

I have a pretty good tutorial for this right here.

[http://www.recentrambles.com/pragmatic/view/59](http://www.recentrambles.com/pragmatic/view/59)

Charlie B.  
[http://www.recentrambles.com](http://www.recentrambles.com)

---

<div class="post-metadata">

**Author:** ![kublai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a3d4f5/32.png) [@kublai](https://www.ruby-forum.com/u/kublai)\
**Post date:** [May 29, 2006, 4:34pm UTC](https://www.ruby-forum.com/t/prompting-user-to-enter-value-to-feed-find/95334/4 "2006-05-29T16:34:20Z")

</div>

charlie bowman wrote:

> Hi,  
> While viewing part of a long list of records, the user may want to do a  
> Find of a specific record (for example, find\_by\_name). The found record  
> is then displayed using the list view. I’ve searched the wiki and  
> couldn’t find a sample or information that will help directly in  
> implementing this function. Any pointers?  
> Thanks!  
> gk
> 
> I have a pretty good tutorial for this right here.
> 
> [http://www.recentrambles.com/pragmatic/view/59](http://www.recentrambles.com/pragmatic/view/59)
> 
> Charlie B.  
> [http://www.recentrambles.com](http://www.recentrambles.com)

Awesome! Live search is what I’d like to use eventually, but for now I’m  
still taking baby steps. The site looks elegant.

thanks  
gk

---

<div class="post-metadata">

**Author:** ![kublai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a3d4f5/32.png) [@kublai](https://www.ruby-forum.com/u/kublai)\
**Post date:** [May 29, 2006, 5:08pm UTC](https://www.ruby-forum.com/t/prompting-user-to-enter-value-to-feed-find/95334/5 "2006-05-29T17:08:24Z")

</div>

Matthew Wastrodowski wrote:  
Hi,  
At this point the grid display is populated from a variable that is set  
in the controller as follows, and hence, there is no explicit query  
string.

def list  
@items = Item.find\_all  
end

What I’m doing, a really simplistic thing, is, at the bottom of the grid  
display for a model, I add a FIND link as follows:

\<%= link\_to “FIND item”,  
:controller =\> “item”,  
:action =\> “list” %\>

When the user clicks on the link, a prompt window should appear and  
allow the user to enter a value. It seems that I’d need a view to  
display the prompt window, collect the search value, and then call the  
list method of the relevant controller and pass the search value. So,  
I’d have to change this list method to something like:

def list  
if @flag  
@items = Item.find\_all  
else  
@items = Item.find\_by\_name(“aValue”)  
end  
end

Somewhere I need to redirect the action to display the list again. But  
the details I don’t have at this point.

Thanks for any help,  
gk

> Gene K. wrote:
> 
> > Hi,  
> > While viewing part of a long list of records, the user may want to do a  
> > Find of a specific record (for example, find\_by\_name). The found record  
> > is then displayed using the list view. I’ve searched the wiki and  
> > couldn’t find a sample or information that will help directly in  
> > implementing this function. Any pointers?  
> > Thanks!  
> > gk
> 
> Could you pass the name through the query string, and if that string is  
> present just overwrite the value  
> in the list @ variable with a find(:all, :conditions =\> [“name =  
> ?”,params[:name]])?
> 
> –  
> Matthew Wastrodowski  
> Web D.  
> [http://blog.familopia.com](http://blog.familopia.com)
> 
> removed\_email\_address@domain.invalid  
> 949 395-7215
