Check if a saved user's name is admin


#1

Hi all,

I have a question about this method in my User model:

Returns true for the (saved) user called “admin”

def is_the_administrator
true if save and name == “admin”
end

The method returns true if the user’s name is admin. However, I only
want to
return true if the state of the object is “saved”, so I call the save
method
first.

I’m wondering if there’s another (better) way to make sure the object is
saved…
Is there??

Thanks,
Mischa.


#2

If I understood you correctly, try something like this? :

def is_the_administrator
if name == ‘admin’
true if save
end
end

Hope this helps… :]
gustav