lib/active_fedora/aggregation/association.rb in activefedora-aggregation-0.4.0 vs lib/active_fedora/aggregation/association.rb in activefedora-aggregation-0.4.1
- old
+ new
@@ -14,10 +14,11 @@
@all_options ||= default_options.merge(super)
end
# Implements the ids reader method, e.g. foo.item_ids for Foo.has_many :items
def ids_reader
+ return [] if @owner.new_record?
if loaded?
load_target.map do |record|
record.id
end
else
@@ -28,9 +29,10 @@
private
# Write a query to find the proxies
def construct_proxy_query
+ raise "Owner must have an identifier" unless @owner.id
@proxy_query ||= begin
clauses = { 'proxyIn' => @owner.id }
clauses[:has_model] = ActiveFedora::Aggregation::Proxy.to_class_uri
ActiveFedora::SolrQueryBuilder.construct_query_for_rel(clauses)
end