Created
June 16, 2016 16:27
-
-
Save mark-dce/75e44d543916083fae36201124e1eda4 to your computer and use it in GitHub Desktop.
Using `contains` for metadata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Codex < ActiveFedora::Base | |
contains 'descMetadata', class_name: 'CodexMetadata' | |
property :title, delegate_to: 'descMetadata', multiple: false | |
property :author, delegate_to: 'descMetadata', multiple: false | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rails c | |
Running via Spring preloader in process 14384 | |
Loading development environment (Rails 4.2.6) | |
2.3.0 :001 > c=Codex.new(id: 'test-2') | |
NoMethodError: undefined method `contains' for Codex:Class | |
Did you mean? constants | |
from /vagrant/hydra-demo/app/models/codex.rb:2:in `<class:Codex>' | |
from /vagrant/hydra-demo/app/models/codex.rb:1:in `<top (required)>' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:457:in `load' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:457:in `block in load_file' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:647:in `new_constants_in' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:456:in `load_file' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:354:in `require_or_load' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:494:in `load_missing_constant' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:184:in `const_missing' | |
from (irb):1 | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in `start' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in `start' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:68:in `console' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require' | |
from /vagrant/hydra-demo/bin/rails:9:in `<top (required)>' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `block in load' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency' | |
from /home/vagrant/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load' | |
from /home/vagrant/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' | |
from /home/vagrant/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' | |
from -e:1:in `<main>'2.3.0 :002 > |
class Codex < ActiveFedora::Base
directly_contains :descMetadata, has_member_relation: ::RDF::URI.new("http://example.com/hasFiles"), class_name: :CodexMetadata
property :title, predicate: ::RDF::Vocab::DC.title, multiple: false, delegate_to: :descMetadata
property :author, predicate: ::RDF::Vocab::DC.creator, multiple: false, delegate_to: :descMetadata
end
This works, I think, am new to the whole hydra thing.
Note for others... see samvera-deprecated/hydra#112
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Any solution to this?