I'm building an app wherein I want to parse bibtex into citations in html. I used the CiteProc-Ruby and bibtex-ruby gems to implement this.
I used this gem. I tried the following code in the Rails console.
cp = CiteProc::Processor.new style: 'apa', format: 'text'
cp.import BibTeX.open('sources.bib').to_citeproc
This works fine. The cp object is a hash of references parsed from the sources.bib file, and with this has I can render html citations in APA or some other format.
So now I want to use this in my app. So I added this to application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
@cp = CiteProc::Processor.new style: 'apa', format: 'text'
@cp.import BibTeX.open('sources.bib').to_citeproc
end
My expectation was to use the @cp object in the views. But instead I get this error message:
uninitialized constant ApplicationController::CiteProc
What is the correct way to do this?