Skip to content

Instantly share code, notes, and snippets.

@mark-dce
Created April 16, 2015 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mark-dce/952e3f45c7dd10d2157b to your computer and use it in GitHub Desktop.
Save mark-dce/952e3f45c7dd10d2157b to your computer and use it in GitHub Desktop.
Getting scalar error on object creation

With these classes:

class CodexMetadata < ActiveFedora::OmDatastream

  set_terminology do |t|
    t.root(path: "fields")
    t.title
    t.author
  end

  def self.xml_template
    Nokogiri::XML.parse("<fields/>")
  end

end

class Codex < ActiveFedora::Base
  contains 'descMetadata', class_name: 'CodexMetadata'

  property :title, datastream: 'descMetadata', multiple: false do |index|
    index.as :stored_searchable
  end
  property :author, datastream: 'descMetadata', multiple: false do |index|
    index.as :stored_searchable
  end

end

When I try to create a new object:

c = Codex.create(id: 'test-3', title: 'On the Equilibrium of Planes', author: 'Archimedes of Syracuse')

I get the following error

ArgumentError: You attempted to set the attribute `title' on `Codex' to a scalar value. However, this attribute is declared as being multivalued.

If I do this, I don't get the same error

property :title, predicate: ::RDF::DC.title, multiple: false do |index|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment