# Filter Results via Post

**URL:** <https://www.ruby-forum.com/t/filter-results-via-post/139916>\
**Category:** Rails\
**Created:** [June 9, 2008, 4:22am UTC](https://www.ruby-forum.com/t/filter-results-via-post/139916 "2008-06-09T04:22:26Z")\
**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:** [June 9, 2008, 4:22am UTC](https://www.ruby-forum.com/t/filter-results-via-post/139916/1 "2008-06-09T04:22:26Z")

</div>

Hi guys,

I’m trying to filter my record results by submitting a post value via  
select field with filter results. It works when the results are  
active, but otherwise it returns a nil object error.

Here is my code: [http://pastie.org/211299](http://pastie.org/211299)

Thanks,

Levi

---

<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:** [June 9, 2008, 10:45pm UTC](https://www.ruby-forum.com/t/filter-results-via-post/139916/2 "2008-06-09T22:45:47Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

On Monday 09 June 2008 04:21:42 removed\_email\_address@domain.invalid wrote:

> I’m trying to filter my record results by submitting a post value via  
> select field with filter results. It works when the results are  
> active, but otherwise it returns a nil object error.

You call params[:vendor][:id] without checking the value of  
params[:vendor]. What if params[:vendor] is nil, as is the case when  
it isn’t passed? 🙂

You’ll probably find it more natural to work with the passed parameters  
if you call the form input vendor\_id instead of vendor[id].

Ciao,  
Sheldon.

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFITZZLpGJX8XSgas0RAkhXAJ9UxqeYoBDL8E5BU72x7999WvXxHwCcC7N+  
vI4fIKqjuUPgCEukxUmaRzo=  
=2+B/  
-----END PGP SIGNATURE-----
