# Help

**URL:** <https://www.ruby-forum.com/t/help/73527>\
**Category:** Rails\
**Created:** [December 20, 2005, 6:19pm UTC](https://www.ruby-forum.com/t/help/73527 "2005-12-20T18:19:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chrisr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@Chrisr](https://www.ruby-forum.com/u/Chrisr)\
**Post date:** [December 20, 2005, 6:19pm UTC](https://www.ruby-forum.com/t/help/73527/1 "2005-12-20T18:19:08Z")

</div>

There is an Audit Type class

Each Audit Type has many Audit Items, they are accessible with the  
method:

AuditType.audit\_items

It is possible to expire audit items, this sets the expired column to 1.  
They still need to be linked with the Audit Type though, so i can not  
delete the foreign key.

When i call AuditType.audit\_items i dont want the items that have been  
expired to show, but i do not know how to do this. Any ideas on the  
best way to do it??

Thanks,  
Chris

---

<div class="post-metadata">

**Author:** ![Chrisr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@Chrisr](https://www.ruby-forum.com/u/Chrisr)\
**Post date:** [November 25, 2008, 4:27pm UTC](https://www.ruby-forum.com/t/help/73527/2 "2008-11-25T16:27:31Z")

</div>

Anything specific we can help with?

Sean

---

<div class="post-metadata">

**Author:** ![Chrisr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@Chrisr](https://www.ruby-forum.com/u/Chrisr)\
**Post date:** [November 25, 2008, 4:32pm UTC](https://www.ruby-forum.com/t/help/73527/3 "2008-11-25T16:32:49Z")

</div>

Some how this conjures up a scene from a John Wayne movie for me.

Adam

---

<div class="post-metadata">

**Author:** ![Chrisr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@Chrisr](https://www.ruby-forum.com/u/Chrisr)\
**Post date:** [July 21, 2009, 1:19pm UTC](https://www.ruby-forum.com/t/help/73527/4 "2009-07-21T13:19:29Z")

</div>

a bit more info would be useful.

2009/7/20 removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> >

–  
[cashflowclublondon.co.uk](http://cashflowclublondon.co.uk)

```
                  ("`-''-/").___..--''"`-._
                   `6_ 6 ) `-. ( ).`-.__.`)
                   (_Y_.)' ._ ) `._ `. ``-..-'
                 _..`--'_..-_/ /--'_.' ,'
                (il),-'' (li),' ((!.-'

```

.

---

<div class="post-metadata">

**Author:** ![Chrisr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@Chrisr](https://www.ruby-forum.com/u/Chrisr)\
**Post date:** [January 8, 2010, 6:22am UTC](https://www.ruby-forum.com/t/help/73527/5 "2010-01-08T06:22:19Z")

</div>

On Thursday 07 January 2010, Jagadeesh wrote:

> |\> \> | && (states.grep(‘open’).empty? ||states.grep  
> |\> empty array and the puts will always be executed.  
> |  
> |Thanks

You don’t need to use grep to see whether an array contains an element.  
You  
can use include?:

if (states.include?(‘closed’) || states.include?(‘feedback’)) &&  
(states.include?(‘open’) || states.include?(‘analyzed’))

Another aopproach is to use the Array & operator, which gives the  
intersection  
between two arrays. You can do something like this:

first\_group = [‘open’, ‘analyzed’]  
second\_group = [‘closed’, ‘feedback’]

if !(states & second\_group).empty? && !(states & first\_group).empty?

The reasoning is that, if states contains either the ‘open’ or the  
‘analyzed’  
entries, then its intersection with first\_group (states & first\_group)  
won’t  
be empty. The same for the second group.

I hope this helps

Stefano
