Last active
August 29, 2015 13:58
-
-
Save pgwillia/10395094 to your computer and use it in GitHub Desktop.
#projecthydra 'uninitialized constant Book::BookMetadata error' seems to be caused by change is Rails class loading
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
# corrected app/models/book.rb | |
class Book < ActiveFedora::Base | |
has_metadata 'descMetadata', type: Datastreams::BookMetadata | |
has_attributes :title, datastream: 'descMetadata', multiple: false | |
has_attributes :author, datastream: 'descMetadata', multiple: false | |
# within app/models/book.rb | |
has_many :pages, :property=> :is_part_of | |
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
# corrected app/models/datastreams/book_metadata.rb | |
class Datastreams::BookMetadata < ActiveFedora::OmDatastream | |
set_terminology do |t| | |
t.root(path: "fields") | |
t.title(index_as: :stored_searchable) | |
t.author(index_as: :stored_searchable) | |
end | |
def self.xml_template | |
Nokogiri::XML.parse("<fields/>") | |
end | |
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
NameError in BooksController#index | |
uninitialized constant Book::BookMetadata | |
Extracted source (around line #2): | |
1 class Book < ActiveFedora::Base | |
2 has_metadata 'descMetadata', type: BookMetadata | |
3 | |
4 has_attributes :title, datastream: 'descMetadata', multiple: false | |
5 has_attributes :author, datastream: 'descMetadata', multiple: false | |
6 | |
class Book < ActiveFedora::Base | |
has_metadata 'descMetadata', type: BookMetadata | |
has_attributes :title, datastream: 'descMetadata', multiple: false | |
has_attributes :author, datastream: 'descMetadata', multiple: false | |
Rails.root: /var/www/sites/hydra-demo | |
Application Trace | Framework Trace | Full Trace | |
app/models/book.rb:2:in `<class:Book>' | |
app/models/book.rb:1:in `<top (required)>' | |
app/controllers/books_controller.rb:7:in `index' | |
Request | |
Parameters: | |
None | |
Toggle session dump | |
_csrf_token: "uq0/63yNVilpiIy7skaQ9t2FBC98TIpH6aeZYivJjVQ=" | |
guest_user_id: "guest_1nreuumgda_76q9ix4mt_1397082483_1@example.com" | |
history: [1] | |
search: {:id=>1, :counter=>"1", :total=>1} | |
session_id: "6367b406f84f2944474bb4ae5240c2b8" | |
Toggle env dump | |
GATEWAY_INTERFACE: "CGI/1.1" | |
HTTP_ACCEPT: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" | |
HTTP_ACCEPT_ENCODING: "gzip,deflate,sdch" | |
HTTP_ACCEPT_LANGUAGE: "en-US,en;q=0.8" | |
REMOTE_ADDR: "192.168.33.1" | |
REMOTE_HOST: "192.168.33.1" | |
SERVER_NAME: "sandbox-server" | |
SERVER_PROTOCOL: "HTTP/1.1" | |
Response | |
Headers: | |
None |
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
# corrected app/models/page.rb | |
class Page < ActiveFedora::Base | |
has_metadata 'descMetadata', type: Datastreams::PageMetadata | |
belongs_to :book, :property=> :is_part_of | |
has_attributes :number, datastream: 'descMetadata', multiple: false | |
has_attributes :text, datastream: 'descMetadata', multiple: false | |
has_file_datastream "pageContent" | |
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
# corrected app/models/datastreams/page_metadata.rb | |
class Datastreams::PageMetadata < ActiveFedora::OmDatastream | |
set_terminology do |t| | |
t.root(path: "fields") | |
t.number index_as: :stored_searchable, type: :integer | |
t.text index_as: :stored_searchable | |
end | |
def self.xml_template | |
Nokogiri::XML.parse("<fields/>") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment