# Automatically create a search form for my model

**URL:** <https://www.ruby-forum.com/t/automatically-create-a-search-form-for-my-model/127863>\
**Category:** Rails\
**Created:** [February 1, 2008, 10:13pm UTC](https://www.ruby-forum.com/t/automatically-create-a-search-form-for-my-model/127863 "2008-02-01T22:13:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 1, 2008, 10:13pm UTC](https://www.ruby-forum.com/t/automatically-create-a-search-form-for-my-model/127863/1 "2008-02-01T22:13:38Z")

</div>

Hi,

Is there a way that scaffold or some other tool can be used to create  
a form that allows you to search for records in a model based on the  
fields of that model? I’ve seen scaffold generates a “list” page, but  
that doesn’t filter based on any criteria. (Or does it?)

My model is called “user” and the controller by which I wish to search  
for records is Admin::UserController.

Thanks, - Dave

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 2, 2008, 12:28am UTC](https://www.ruby-forum.com/t/automatically-create-a-search-form-for-my-model/127863/2 "2008-02-02T00:28:07Z")

</div>

On 2/1/08, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there a way that scaffold or some other tool can be used to create  
> a form that allows you to search for records in a model

Records aren’t in a model, they’re in the database.

> based on the  
> fields of that model?

Well, yeah… if you search a table then you have to use one it’s  
fields to search by.

> I’ve seen scaffold generates a “list” page, but  
> that doesn’t filter based on any criteria. (Or does it?)

No clue, I don’t use scaffolding.

> My model is called “user” and the controller by which I wish to search  
> for records is Admin::UserController.

The controller has nothing to do with the model in this respect.

@users = User.find( :all, :conditions =\> [‘name = ?’, params[:name] ] )

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)
