requiring uninitialized errors
atstockland opened this issue · 6 comments
I'm assuming the require code needs to go at the top of application.rb?
application.rb
require 'rails/all'
require 'htmlbeautifier'
beautiful = HtmlBeautifier.beautify(messy).
When starting the server I experience errors:
- when using "beautiful = HtmlBeautifier.beautify(messy)" I get "
method_missing': undefined local variable or method
messy' for..." - when using 'HtmlBeautifier::Beautifier.new($stdout).scan("\n\n\n")' I get "uninitialized constant HtmlBeautifier::Beautifier".
Is my config wrong or is there a bug? Thanks!
These don't look like bugs to me! In your first example, you try to beautify a variable (messy
) that hasn't been defined yet. In the second, it looks like the library has not been require
d.
What are you actually trying to do?
Im simply trying to install the gem and use it with the BeautifyRuby ST3 plugin. This code (as indicated in the README), results in errors because messy isn't defined.
application.rb
require 'htmlbeautifier'
beautiful = HtmlBeautifier.beautify(messy)
What is messy? Am I supposed to define it or does the gem? If I define it....what is it...a path? The README does not indicate where the code is supposed to go or how to use it. Where do I use beautiful = HtmlBeautifier.beautify(messy)?
I also tried putting the above code in spring.rb where rubygems and bundler are required...but, with the same result.
Thanks for the help!
Ah!
This is a tool that the ST3 plugin uses, but this isn't the ST3 plugin and I don't actually know anything about the plugin or Sublime Text in general. What I do know is that you shouldn't need to alter your Rails application to be able to use the plugin.
You'll probably be able to get help from the maintainer of the plugin, here: https://github.com/CraigWilliams/BeautifyRuby
Ok. Thanks. BeautifyRuby specifically addresses the issue I am having in the readme. However, it seems to be related to the installation of this gem (not the plugin).
"Erb html templates uses Paul Battley's htmlbeautifier gem. This (as well as rubygems) is assumed to be installed as seen by the ruby interpreter. Note that if you beautify an erb file but htmlbeautifier is not found, the error message is 'check your ruby interpreter settings', do not be misled."
I assumed my issue is that htmlbeautifier is not config'ed correctly. Can you confirm the following code should work for installation of htmlbeautifier gem? Thanks again!
application.rb
require 'htmlbeautifier'
beautiful = HtmlBeautifier.beautify(messy)
I can confirm that won't work. It looks like you need to install the gem in whichever path ST3 is using. This (on the command line) should do it:
sudo gem install htmlbeautifier
I've already installed the gem via gemfile. Thanks for the help!