On 3 April 2012 09:12, amvis <[email protected]> wrote:
> class User < ActiveRecord::Base
>   has_one  :system_admin
> end
>
> @user = User.find_by_user_name(user_name)
>               if [email protected]_admins.nil?
>                  puts 'am a sys_admin'
>
> The above code gives error

Since you've defined the association as a has_one, you should use it
in the singular:
  if [email protected]_admin.nil?

but "!...nil?" is a bit stinky; either use:
  if @user.system_admin
or
  unless @user.system_admins.nil?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to