On Mar 17, 2006, at 1:03 PM, Ryan Williams wrote:

>> How about something like:
>>
>> todo = Hash[ *TASKS.reject do |name, desc|
>>    @current_assignments.any? { |assign| assign.tasks == name }
>> end.flatten ]
>
> Okay... this seems to work fine right up to the .flatten
> I created a method in my model like so:
>
> def self.get_unassigned(assigned)
>     Hash[ *TASKS.reject do |name, desc|
>           assigned.any? { |assign| assign.task == name }
>           end.flatten ]
> end
>
> with "assigned" being @currently_assigned.
>
> Rails is giving me:
>
> NoMethodError in Admin#show
>
> undefined method `flatten' for {"homework"=>"Do Your Homework!"}:Hash

This is me being dumb and not realizing how clever Ruby is.  You can  
drop the flatten() and the Hash[] call:

TASKS.reject do |name, desc|
   assigned.any? { |assign| assign.task == name }
end

Hope that helps.

James Edward Gray II