Rails: Can I use the ruby gem better_errors with any frontend framework? - ruby-on-rails

I have a backboneJS app working with the gem rabl on Ruby on Rails

Better error only shows ruby errors (or rather server side errors), if it's a javascript error it will occur on the browser not the server, if the assets have errors it should appear in the precompilation, so you probably are covered too.
Anyways, using better errors has no downsides, cause the cases that won't work with better errors won't work with the basic error pages without better errors.
PS: If you want to debug an ajax request you can try opening the browser console and click the request that has an error and choose something that means close to 'open this request in a new tab'

Related

Ruby on Rails Runtime Console

I am trying to find a way to get a rails console for a program during runtime with all instantiated variables. The normal rails console does not have access to any instantiated variables of its respective running application. For example, when a rails application crashes during runtime, a webpage will load with the error listed in red text, a snippet of the code where the error was raised, and a console at the bottom with access to variables instantiated during runtime.
See image below for console im talking about
The best thing I could find was a gem called pry, which seems to allow you to access a console during runtime by adding the line 'binding.pry' in your code at the point where you want access to the console. I would be fine with this, but seeing as how rails already gives you access to this when your app crashes, I would think there is a "vanilla" way to do this. Unfortunately I can't find anything online about this feature in rails. This seems like such a valuable tool for debugging I can't see why rails doesn't implement this. Is there a better way to debug during runtime? a better gem?
I will suggest you to use Better Errors
Better Errors replaces the standard Rails error page with a much better and more useful error page. It is also usable outside of Rails in any Rack app as Rack middleware.

How do I debug errors with ActiveAdmin with Ruby on Rails?

There is a rails application that uses bunch of gems one of which is ActiveAdmin.
Dashboard works OK, but other custom tabs gets a 500 response.
How do I enabled debugging/logging inside ActiveAdmin gem to get to the bottom of this problem?
Corresponding generic question is this: what are the ways to enable debugging on rails apps with multiple gem dependencies?
1) Check your development.log file after hitting the custom tab page and see where the error was. The log should give you a stack trace or at least tell you the last controller that was hit. You can use this information to work backwards and find out where you code is breaking.
2) Once you have found the broken spot in the code you can use raise or pry debugger to inspect variables/methods to help you debug.
This turned out to be a version mismatch between the mongoid interface and the active admin interface.Thanks for all the help.

Silent error and 500 page instead of debug output in development on Haml::SyntaxError

Got a weird issue. Seems something very simple..
The issue is when I make a Syntax error in HAML or ERB template in my Rails app, it renders 500 error page and no debug output with the error details. BUT if I simulate another type of error, for example
form_for -> for m_for (add whitespace in helper)
I receive error page I expect. http://cl.ly/image/1b1K3c1a0G3w
Versions:
Rails v3.2.12 (tried to upgrade to 3.2.14)
Ruby 1.9.3-p448
HAML 3.1.7(tried 4.x.x) - but no debug output not only in HAML, erb template also does the same
The encoding of all files is US-ASCII
Trued to use magic_encoding gem - no luck
The issue was in splunk(http://www.splunk.com/) - errors collector. It catch exceptions from views without any notification in development mode. Issue was solved by moving in out in production group.
Also gem better_errors helped to catch errors in any way with and without splunk.

Empty responses with explorer after rails post

Im facing a hairy bug when submitting a ruby on rails form on production environment, consisting on a blank response and page displayed by internet explorer 7-9.
This bug does not happen with any other common browsers and it's even quite random with ie as it sometimes works fine.
When failing, logs show a "200 OK in 0ms" which made me think about caching, but that didn't seem to be the source. After some debugging it looks like the server returns the 200 reply without even running the code; it doesn't stop on any breakpoint placed inside the action, tough logs show it was processed by it.
The failing form is a custom devise registration one, using devise in a spree 0.60 application and ruby on rails 3.0.7
Server is thin behind nginx.
Any suggestions? Thank you.

How can I prevent cache/cookies from affecting the path of ckeditor javascript files in a production rails app?

I have a built a rails app in which I am using the ckeditor 3.5.1 together with the ckeditor gem.
When running in development, everything works fine. But when I run in production, I get errors.Sometimes, the text_area with the ckeditor does not show up. But when I clear my cache and cookies, everything works fine. Then after a while, the error comes up again. The error comes up more often than not.
Closer investigation reveals that when the error occurs, some files like staging.domain.com/javascripts/ckeditor/config.js are instead being requested from staging.domain.com/posts/config.js which is naturally non-existent
(posts is from my Post model)
How can the cache/cookies affect which path the files are served from?
Does anyone know what else might be wrong and how I can fix it?
P.S. I am using Phusion passenger in production.
It would seem the problem was being cased by mod_pagespeed which was activated. By disabling it, everything came back to normal.
I am curious though, about how this was happening.

Resources