The trouble is, "any?" works when "roles" is an array. Sometimes, however, user.roles returns only one object any other times my return nil. So calling roles.any? causes an error. How do I work around this?
My setup is User has_many Accounts through :roles, and vice-versa.
Everaldo Gomes
unread,
May 31, 2012, 1:22:42 PM5/31/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rubyonra...@googlegroups.com
Hi!
There are many ways to solve this problem.
One sugestion, maybe not the better: you can use the method kind_of?
to see if roles is a Array.
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To view this discussion on the web visit