rails How to migration find_all_by_

52 views Asked by At

Hi I migrate an app from Rails 2 to Rails 7.04.

I don't see how to rewrite :

self.accepted_roles.find_all_by_name(role_name).any? { |role| role.users }

users = self.accepted_roles.find_all_by_name(role_name).collect { |role| role.users }

users.flatten.uniq if users

I think self.roles.where("name="role_name).find_each but .any? and .collect

I don't find Rails 2 documentation. Help is welcome

1

There are 1 answers

7
Themis Nikellis On

I think that .where() is what you are looking for.