Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- remove instance variable warnings

  • Loading branch information...
commit e0cf70899ad730f09a081dde6f4c0dbb03c51f37 1 parent 95d5305
@gramos authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 activeresource/lib/active_resource/associations.rb
View
7 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
Please sign in to comment.
Something went wrong with that request. Please try again.