Hello,
Most of You might find this very weird
but I have no way out of it
I have a method that return a Array Object
the method goes like this in User Model
def accessible_websites
if self.is_super_admin?
if Super Admin Display all Website
Website.all
elsif self.is_admin?
if only Admin then display all websites only for the account for
which he is admin.
self.account.websites
else
## display all the website for the account in the groups which he
is been assigned to(i.e Normal User)
self.account.websites.find(:all,:joins => [:group_websites =>
{:group => :users}],:conditions=>[“users.id =?”,self]).uniq
end
end
the code is made generic in User Model to avoid code duplication else
where
Problem is
If its a Normal User
the below code return a “Array” whose superclass is “Object” and not
“ActiveRecord::Base”
Here what I meant
current_user.accessible_website.class.superclass => Object
so
current_user.accessibe_website.find_by_id() ## return error
or
current_user.accessible_website.find_by_status(“disable”) ## return
error
rightly so coz it not an Array of ActiveRecord::Base Object
Here what i meant
if Someone do this
Website.all.class.superclass => “ActiveRecord::Base” so the object is
still suitable for any further SQL related task like “find_by_id” etc
because the object return has a superclass “ActiveRecord” and not
“Object”
So …
Is there a way can I Mix the “ActiveRecord::Base” method in “Array” of
superclass “Object” so that hence forth the object is suitable for any
further SQL related task
Regards
Viren N.