Permalink
Browse files

- remove instance variable warnings

  • Loading branch information...
1 parent 95d5305 commit e0cf70899ad730f09a081dde6f4c0dbb03c51f37 @gramos committed Sep 28, 2010
Showing with 4 additions and 3 deletions.
  1. +4 −3 activeresource/lib/active_resource/associations.rb
@@ -25,13 +25,14 @@ def has_one(resource, opts = {})
klass_name = opts[:class_name].nil? ? resource : opts[:class_name]
#----------------------------------------------------------------------#
- # Define accessor method for resource
+ # Define accessor method for resource
#
#----------------------------------------------------------------------#
define_method(klass_name) do
- if instance_variable_get("@#{resource}").nil?
+ if !instance_variable_defined?("@#{resource}") ||
+ instance_variable_get("@#{resource}").nil?
instance_variable_set("@#{resource}",
- h[:klass].find(:first, :params => { h[:association_col] => id }) )
+ h[:klass].find(:first, :params => { h[:association_col] => id }))
end
return instance_variable_get("@#{resource}")
end

0 comments on commit e0cf708

Please sign in to comment.