Forum: Ruby on Rails Help

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cd8c9864d88bcafc164d8fdb820cc451?d=identicon&s=25 Chrisr (Guest)
on 2005-12-20 18:19
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
8802b1fa1b53e2197beea9454244f847?d=identicon&s=25 Sean Cribbs (seancribbs)
on 2008-11-25 16:27
(Received via mailing list)
Anything specific we can help with?

Sean
44261b1dd4d1f942a43d19c45e3a22e4?d=identicon&s=25 Adam van den Hoven (Guest)
on 2008-11-25 16:32
(Received via mailing list)
Some how this conjures up a scene from a John Wayne movie for me.

Adam
A4ae6aac9990a6c84a97e4c753dda339?d=identicon&s=25 Developer In London (Guest)
on 2009-07-21 13:19
(Received via mailing list)
a bit more info would be useful.

2009/7/20 marcejef@gmail.com <marcejef@gmail.com>

>
>
>
> >
>


--
cashflowclublondon.co.uk

                      ("`-''-/").___..--''"`-._
                       `6_ 6  )   `-.  (     ).`-.__.`)
                       (_Y_.)'  ._   )  `._ `. ``-..-'
                     _..`--'_..-_/  /--'_.' ,'
                    (il),-''  (li),'  ((!.-'
.
C40020a47c6b625af6422b5b1302abaf?d=identicon&s=25 Stefano Crocco (crocco)
on 2010-01-08 06:22
(Received via mailing list)
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
This topic is locked and can not be replied to.