Skip to content

Instantly share code, notes, and snippets.

@afred
Last active August 29, 2015 14:22
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 afred/75b82263e35b7614df59 to your computer and use it in GitHub Desktop.
Save afred/75b82263e35b7614df59 to your computer and use it in GitHub Desktop.

app/models/generic_file.rb

class GenericFile < ActiveFedora::Base
  has_metadata 'descMetadata', type: MediaAnnotationDatastream
  has_attributes :title_attributes, datastream: 'descMetadata', multiple: true
  attr_accessible   :title_attributes     # <== needs to be changed to use strong params, yes?
end

app/models/datastream/media_annotation_datastream.rb

class MediaAnnotationDatastream < RDF::EbuCore::Datastream
  property :title, predicate: RDF::EbuCore::Vocabulary.title, class_name: Title
  accepts_nested_attributes_for :title
end

and the offending test line looks something like this...

generic_file = GenericFile.find(generic_file_id)

attributes = {
  "title_attrributes" => [
    {"title_type" => "Series", "value" => "Sesame Street"},
    {"title_type" => "Program", "value" => "Cookie Did It All for the Nookie"}
  ]
}

# Here is the line that triggers the error
generic_file.attributes = attributes

... and produces this error...

NoMethodError: undefined method `title_attributes' for #<MediaAnnotationDatastream:0x007fdcaf7a44d0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment