Fixing association bug to avoid searching when foreign key is nil
This commit is contained in:
parent
226fe3bf38
commit
b81d37fc02
2 changed files with 7 additions and 1 deletions
|
@ -109,7 +109,7 @@ module CouchRest
|
|||
base = options[:proxy] || options[:class_name]
|
||||
class_eval <<-EOS, __FILE__, __LINE__ + 1
|
||||
def #{attrib}
|
||||
@#{attrib} ||= #{base}.get(self.#{options[:foreign_key]})
|
||||
@#{attrib} ||= #{options[:foreign_key]}.nil? ? nil : #{base}.get(self.#{options[:foreign_key]})
|
||||
end
|
||||
EOS
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue