# Find\_all\_by and select boxes?

**URL:** <https://www.ruby-forum.com/t/find-all-by-and-select-boxes/172189>\
**Category:** Rails\
**Created:** [July 16, 2009, 2:44pm UTC](https://www.ruby-forum.com/t/find-all-by-and-select-boxes/172189 "2009-07-16T14:44:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Valerie\_Fehst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/7ba0ec/32.png) [@Valerie\_Fehst](https://www.ruby-forum.com/u/Valerie_Fehst)\
**Post date:** [July 16, 2009, 2:44pm UTC](https://www.ruby-forum.com/t/find-all-by-and-select-boxes/172189/1 "2009-07-16T14:44:47Z")

</div>

So…let’s have a look if I understood the issue:

-Find\_all\_by is actually the same like Find(:all), however Find\_all\_by  
is much shorter and less complicated than the syntax of Find(:all)

-So in my CONTROLLER it says @files = find(:all) however I don’t want  
to see all files displayed in my selection box, because I only want to  
see the foles whose mandant\_id is the same like the mandant\_id in  
invoice.  
So i decided to change the @files = find(:all) into =\>  
_@files =File.find\_all\_by\_mandant\_id(Invoice.mandant\_id)_

But this doesnÂ´t work so does any one has an inspiration to get it  
working??

If so please help me!! thnx a lot!! =D  
Valli

---

<div class="post-metadata">

**Author:** ![Valerie\_Fehst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/7ba0ec/32.png) [@Valerie\_Fehst](https://www.ruby-forum.com/u/Valerie_Fehst)\
**Post date:** [July 16, 2009, 4:51pm UTC](https://www.ruby-forum.com/t/find-all-by-and-select-boxes/172189/2 "2009-07-16T16:51:44Z")

</div>

Hi Valerie,

On Thu, 2009-07-16 at 12:30 +0200, Valerie Fehst wrote:

> @files =File.find\_all\_by\_mandant\_id(Invoice.mandant\_id)  
> Invoice is a class. What you’re looking for is, I assume, the  
> mandant\_id of a _particular_ invoice. So you need to use the mandant\_id  
> of that. Assuming you have grabbed that somewhere with another find  
> like …

@my\_invoice = Invoice.find(:first)

then your find\_by will look like…

@files = File.find\_all\_by\_mandant\_id(@my\_invoice.id)

Note that using ‘File’ as a model name is potentially problematic since  
File is also a ruby class.

HTH,  
Bill
