Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with rails mountable engine #93

Closed
ghost opened this issue Jan 20, 2013 · 8 comments · Fixed by #94
Closed

Doesn't work with rails mountable engine #93

ghost opened this issue Jan 20, 2013 · 8 comments · Fixed by #94

Comments

@ghost
Copy link

ghost commented Jan 20, 2013

Hi! I encountered a problem with simultaneous use of better_errors and rails mountable engines.

If you mount rails engine at some enterpoint in your main app routes, errors which are happened in the app would be normally rendered by the gem. However, errors in the engine code would be rendered partially.

This screenshot shows error in main app code.
 2013-01-21 2 40 39

And this screen shows error in code which is covered by rails engine. It's almost empty.
 2013-01-21 3 02 44

In logs you could see something like that ActionController::RoutingError (No route matches [POST] "/raise_engine_error/__better_errors/70309963973640/variables")

As far as I know rails mountable engines work like middlewares so problem should be with better_errors middleware injection.

I also prepared a dummy app with simple rails engine to check the problem in live:
https://github.com/rgt600/better_errors_engine_error
Just clone it, cd to ./test/dummy, bundle install (it's isolated so safe for your env), "bundle e rails s" and go in your browser to /raise_engine_error. It would be broken. And if you go to /raise_app_error page would be rendered normally.

Thanks for any help!

@virusman
Copy link
Contributor

In case of this error, the AJAX request path will be something like '/raise_engine_error/__better_errors/70198016361960/variables' instead of just '/__better_errors/70198016361960/variables', so better_errors middleware doesn't match the regexp and passes the request over to the app. I haven't figured out why the path is different yet.

@haileys
Copy link
Collaborator

haileys commented Jan 22, 2013

@rgt600: What happens if you click "All frames"?

@haileys
Copy link
Collaborator

haileys commented Jan 22, 2013

Also, how do I get the sample app you provided running?

@virusman
Copy link
Contributor

Replace

gemspec path: '~/dev/better_errors_engine_error'

with

gemspec path: '../..'

in test/dummy/Gemfile

@virusman
Copy link
Contributor

better_errors prefixes its API calls with uri_prefix which is env["SCRIPT_NAME"], but the regex only matches the root path. In case of better_errors_engine_error, env["SCRIPT_NAME"] will be '/better_errors_engine_error'.

@ghost
Copy link
Author

ghost commented Jan 22, 2013

@virusman: thanks for your investigation! If I understand you right, this issue is unfixable with gem's current architecture, isn't it?

@charliesome: sorry for inconvenience with my rep. It should work now. And it's bundled against gem's edge (with virusman's fix)

"All frames" seems to work.
 2013-01-23 2 40 12

@thomet
Copy link
Contributor

thomet commented Jan 28, 2013

I think with my PR (#103) this should be fixed.

@haileys
Copy link
Collaborator

haileys commented Mar 9, 2013

Fixed in #103.

@haileys haileys closed this as completed Mar 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants