last day (15 days later) » 

9:50 PM
0
Q: Better Errors Gem not working in local browser

user2974739I have tried all the things from this link to try to solve this, but it doesn't work Better Errors Gem not working in local browser, no errors visible This is what I have in my gem file group :development, :test do gem 'pry' gem 'pry-rails' gem 'rspec-rails' gem 'coderay' gem 'erub...

 
Did you try to restart rails?
 
I did stop and start the local server.
 
Could you, please, show all contents of your config/environments/development.rb? Btw, if you use better_errors only on localhost, you don't need that allow_ip! line.
 
I updated the question with the contents of development.rb
 
Please, add the line BetterErrors::Middleware.allow_ip! "0.0.0.0/0" there.
 
9:50 PM
Is there a specific place I add this line? I get this error when I add it development.rb:35:in block in <top (required)>': undefined method allow_ip!' for BetterErrors::Middleware:Class (NoMethodError)
 
Well, it's just need to be inside Rails.application.configure do block. Also, it may still be the chance, that your app is still running if you use spring. Run spring stop prior starting your rails.
 
I put in the Rails.application.configure do block. The last part of your message got cut off.
 
Does it work at all if you remove that line altogether?
 
spring stop
Spring is not running
I doesn't work when I remove the line BetterErrors::Middleware.allow_ip! "0.0.0.0/0". And I get an error when I add that line the development.rb file
 
Do you get any error when you remove that line?
 
10:04 PM
No. The rails server starts, but better_errors doesn't work.
 
what version of rails do you have?
 
rails -v
Rails 4.1.1
 
I'm out of options. Try to move better_errors to :development group only. Now it is situated in :development and :test
very strange situation actually
 
hmm...I tried that as well. I'm not sure what's going on either.
 
what server do you use?
webrick, thin, puma?
 
10:11 PM
it's my local mac
puma
 
can't say anything right now without running your code. Can you share your repository?
 
I wish I could. I'm working on proprietary code.
 
did you try this in your gemfile, gem 'better_errors' , '~> 2.1.1'
then bundle , then restart the server
set the version
 
yep...i tried many different versions. of the gem
 
do you have other middleware installed?
 
10:25 PM
not that i'm aware of
 
can you execute this in your console BetterErrors::Middleware.methods.first
it should return :allow_ip!
 
BetterErrors::Middleware.methods.first
-bash: BetterErrors::Middleware.methods.first: command not found
It seems like the gem didn't get properly installed?
 
it should be your rails console
 
run rails c first
 
10:27 PM
(y)
 
BetterErrors::Middleware.methods.first
=> :yaml_tag
 
can you show us the return of
BetterErrors::Middleware.methods
 
pry(main)> BetterErrors::Middleware.methods
=> [:yaml_tag,
:allocate,
:new,
:superclass,
:json_creatable?,
:class_attribute,
:superclass_delegating_accessor,
:descendants,
:subclasses,
:to_template,
:to_v8,
:weakcell,
:freeze,
:===,
:==,
:<=>,
:<,
:<=,
:>,
:>=,
:to_s,
:inspect,
:included_modules,
:include?,
:name,
:ancestors,
:instance_methods,
:public_instance_methods,
:protected_instance_methods,
:private_instance_methods,
:constants,
:const_get,
:const_set,
:const_defined?,
:class_variables,
it's pretty long
it still goes on for a while
 
it seems like you miss only the :allow_ip class method
 
It might be there. The output I pasted is not everything
 
10:33 PM
can you create a file in your initilizers folder , call it better_errors.rb
yes it should be the first one
then create this
module BetterErrors
class Middleware
ALLOWED_IPS = Set.new

# Adds an address to the set of IP addresses allowed to access Better
# Errors.
def self.allow_ip!(addr)
ALLOWED_IPS << IPAddr.new(addr)
end
end
then restart your server
 
better_errors.rb:10: syntax error, unexpected end-of-input, expecting keyword_end (SyntaxError)
module BetterErrors
class Middleware
ALLOWED_IPS = Set.new

# Adds an address to the set of IP addresses allowed to access Better
# Errors.
def self.allow_ip!(addr)
ALLOWED_IPS << IPAddr.new(addr)
end
end
 
i forgot the end of the model
add an end at the end
 
oh yeah...
tried it and it still didn't work
 
still the same message ?
 
yep...it defaults to the error page that a regular user would see
instead of the better errors error page
 
10:44 PM
btw, do you test it on the routing error page?
it seems better_errors do not work with routing errors
 
no. i put a syntax error in my code to test it and go to the controller
it then just routes to the error page that a regular user would see
localhost:3000/home/index
 
I searched my entire mac and can't find the file better_errors/middleware.rb
 
can you add this in your file better_errors.rb inside the Middleware class , after allow_ip! method
allow_ip! "127.0.0.0/8"
allow_ip! "::1/128" rescue nil # windows ruby doesn't have ipv6 support
then restart your server and test again
 
nope...same thing
do you know why i can't find the file better_errors/middleware.rb
i just looked for it via the finder
 
10:54 PM
maybe it's inside .rvm or .rbenv, hidden folder
 
how do you find it?
 
it depends
you use rvm or rbenv ?
 
i think rvm
 
it's at the location when you installed rvm, generally inside the /home/your_name/.rvm/...
 
try this: gem pristine better_errors
 
10:57 PM
let me try
gems to pristine condition...
Restored better_errors-0.6.0
Restored better_errors-2.0.0
Restored better_errors-2.1.1
running the server
nope
same thing
 
you should remove the better_errors.rb file
then try again without the file
 
where is the file? pwd
/Users/vipul/.rvm
vipul$ ls
LICENSE archives docs gems installed.at patches src
README bin environments gemsets lib patchsets tmp
RELEASE config examples help log rubies user
VERSION contrib gem-cache hooks man scripts wrappers
 
try , ls -a
you can try , gem remove better_errors , then gem install better_errors
 
gem remove better_errors
ERROR: While executing gem ... (Gem::CommandLineError)
Unknown command remove
gem uninstall better_errors

Select gem to uninstall:
1. better_errors-0.6.0
2. better_errors-2.0.0
3. better_errors-2.1.1
4. All versions
> 4
Successfully uninstalled better_errors-0.6.0
Successfully uninstalled better_errors-2.0.0
Successfully uninstalled better_errors-2.1.1
 
yes it was uninstall , sorry!
 
11:05 PM
em install better_errors
Fetching: better_errors-2.1.1.gem (100%)
Successfully installed better_errors-2.1.1
Parsing documentation for better_errors-2.1.1
Installing ri documentation for better_errors-2.1.1
Done installing documentation for better_errors after 2 seconds
1 gem installed
vipul$ rails s -e development
Could not find better_errors-0.6.0 in any of the sources
Run `bundle install` to install missing gems.
why is it looking for better_errors-0.6.0 ?
 
because it is in your Gemfile.lock
 
you need to updated with bundle install
 
i'll delete my lock file
and bundle install
 
no it get's updated
 
11:08 PM
ahh!
bundle install
I tried gem install libv8 -v '3.16.14.11 but it didn't work
 
You need to wait longer, it downloads ~100mb file
It's actually a bad idea to delete Gemfile.lock, since all your dependencies will be updated
Your app may break in many ways
I mean run bundle install after deleting Gemfile.lock
 
i did bundle install again and there were no errors, however better_errors still doesn't work
 
11:23 PM
what error message did you get ?
 
there is no error message. the page just defaults to the views/errors/500.html.erb page
 
did you delete better_errors.rb in your initilizers folder ?
 
no...i thought you meant a different one. let me try that
 
don't forget to restart your server
 
nope...still goes back to the 500.html.erb page
 
11:31 PM
when you remove BetterErrors::Middleware.allow_ip! ... does it work ?
can you show us your Gemfile
 
i removed BetterErrors::Middleware.allow_ip! from my development.rb file and it still doesn't work
BetterErrors::Middleware.allow_ip!
source 'https://rubygems.org'
ruby '2.1.2'
# rails gems
gem 'rails', '4.1.1'
gem 'pg'
gem 'coffee-rails', '~> 4.0.0'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development

# web server
gem 'puma'

# admin user management
gem 'rails_admin'
gem 'cancan'

# infrastructure
gem 'devise'
gem 'devise_invitable', '~> 1.3.4'
gem 'paperclip'
gem 'aws-sdk', '~> 2'
gem 'rmagick'
gem 'newrelic_rpm'
gem 'google-analytics-rails'

# front-end gems
gem 'sass-rails', '~> 4.0.3'
what is libv8?
i keep getting the error about that gem when i do bundle install
do you think that could be causing the error?
should i try bundle install libv8?
 
no , it's a javscript engine
to run javascript in your server
 
ok...well thanks for all your efforts. i need to step away for a bit.
 
ok , hope you good luck
 

last day (15 days later) »