> On Feb 7, 2016, at 8:52 PM, David Williams <[email protected]> wrote:
> 
> I got it! had to set self.is_admin? Thanks for pointing me in the right 
> direction.

I'm not sure this is doing what you think it is. If you have a boolean column 
on your model called is_admin, then Rails will define an is_admin? method for 
you (it actually does this for all columns, not just the booleans). When you 
redefine your is_admin? method to self.is_admin?, you are moving it up to 
become a class method, which means that when you call @user.is_admin? you are 
getting the Rails-added version of the method. If you called User.is_admin? you 
would get an error, or nothing, because the method as you wrote it here doesn't 
make a lot of sense. (As an instance method, it will always return true, 
assuming that all of your users have a non-empty username. As a class method, 
assuming you called it, I think you would get an error saying that 
self.username is undefined.)

Walter

> 
> -- 
> Posted via http://www.ruby-forum.com/.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/ea8144300fcde31b5e123e495c61a58e%40ruby-forum.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/F56DB7BA-CB60-41C8-A931-71ADC196A2EB%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to