Forum: Ruby on Rails model questions about using ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B0be4bfef5a22697a0f44f4fe295aaef?d=identicon&s=25 James Whittaker (aftershock)
on 2006-03-29 10:23
I have an employee model. I want to be able to say:

employee.isAdmin? in my view

so in the model I have:

def isAdmin?
if self.role.name == "Administrator"
true
end
end

When run I get a blank screen, no errors or anything, whats wrong with
the isAdmin? method? If I take out the if self... line it is returning
true.
B0be4bfef5a22697a0f44f4fe295aaef?d=identicon&s=25 James Whittaker (aftershock)
on 2006-03-29 10:32
James Whittaker wrote:
> I have an employee model. I want to be able to say:
>
> employee.isAdmin? in my view
>
> so in the model I have:
>
> def isAdmin?
> if self.role.name == "Administrator"
> true
> end
> end
>
> When run I get a blank screen, no errors or anything, whats wrong with
> the isAdmin? method? If I take out the if self... line it is returning
> true.

Sorry solved!

I changed it to

def isAdmin?
true if self.role.name == "Administrator"
end

and it would have helped if i spelled administrator correctly elsewhere!
This topic is locked and can not be replied to.