Skip to content

Instantly share code, notes, and snippets.

@mark-dce
Created October 8, 2014 21:38
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/6e96f6188292ea897953 to your computer and use it in GitHub Desktop.
Save mark-dce/6e96f6188292ea897953 to your computer and use it in GitHub Desktop.
Namespacing problem
With a gemfile like this:
source 'https://rubygems.org'
gem 'nokogiri', '~> 1.6.3.1'
....
And a model defined like this
class Record < ActiveRecord::Base
def to_pbcore_xml
xml = '<?xml version="1.0"?><pbcoreDescriptionDocument xmlns="http://www.pbcore.org/PBCore/PBCoreNamespace.html" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.pbcore.org/PBCore/PBCoreNamespace.html" xsi:schemaLocation="http://www.pbcore.org/PBCore/PBCoreNamespace.html"></pbcoreDescriptionDocument>'
Nokogiri::XML(xml)
end
end
I'm getting an error like this
NameError in RecordsController#show
uninitialized constant Record::Nokogiri
Extracted source (around line #22):
def to_pbcore_xml
xml = '<?xml version="1.0"?><pbcoreDescriptionDocument xmlns="http://www.pbcore.org/PBCore/PBCoreNamespace.html" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.pbcore.org/PBCore/PBCoreNamespace.html" xsi:schemaLocation="http://www.pbcore.org/PBCore/PBCoreNamespace.html"></pbcoreDescriptionDocument>'
Nokogiri::XML(xml)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment