Giter Site home page Giter Site logo

xray-rails's Introduction

Xray-rails

Gem Version Build Status

Reveal your UI's bones

The dev tools available to web developers in modern browsers are great. Many of us can't remember what life was like before "Inspect Element". But what we see in the compiled output sent to our browser is often the wrong level of detail - what about visualizing the higher level components of your UI? Controllers, view templates, partials, JS templates, etc.

Xray is the missing link between the browser and your app code. Press command+shift+x (Mac) or ctrl+shift+x to reveal an overlay of the files that rendered your UI, and click anything to open the file in your editor.

Screenshot

Current Support

Xray is intended for Rails 3.1+ and Ruby 1.9+.

So far, Xray can reveal:

  • Rails views and partials
  • Javascript templates if using the asset pipeline with the .jst extension

Installation

Xray depends on jQuery.

This gem should only be present during development. Add it to your Gemfile:

group :development do
  gem 'xray-rails'
end

Then bundle and delete your cached assets:

$ bundle && rm -rf tmp/cache/assets

Restart your app, visit it in your browser, and press command+shift+x (Mac) or ctrl+shift+x to reveal the overlay.

Note about config.assets.debug

By default, Xray will insert itself into your views automatically. To do this, config.assets.debug = true (Rails' default) must be set in development.rb.

Otherwise, you can insert Xray's scripts yourself, for example like so in application.js:

//= require jquery
//= require xray

Configuration

By default, Xray will check a few environment variables to determine which editor to open files in: $GEM_EDITOR, $VISUAL, then $EDITOR before falling back to /usr/local/bin/subl.

You can configure your editor of choice either by setting one of these variables, or in Xray's UI, or in an ~/.xrayconfig YAML file:

:editor: '/usr/local/bin/mate'

For something more complex, use the $file placeholder.

:editor: "/usr/local/bin/tmux new-window 'vim $file'"

How this works

  • At run time, HTML responses from Rails are wrapped with HTML comments containing filepath info.
  • A middleware inserts xray.js, xray.css, and the Xray bar into all successful HTML response bodies.
  • When the overlay is shown, xray.js examines the inserted filepath info to build the overlay.

Disabling Xray

Xray augments HTML templates by wrapping their contents with HTML comments. For some environments such as Angular.js, this can cause Angular templates to stop working because Angular expects only one root node in the template HTML. You can pass in the option xray: false to any partial render statements to ensure Xray does not augment that partial. Example:

render partial: 'my_partial', locals: { xray: false }

Note that this disables Xray's HTML comment wrappers for my_partial, but not any sub-partials rendered within that template, if any. You must pass xray: false to each render call where you want Xray disabled.

Currently there is no way to disable Xray entirely for a given request. If this feature is important to you, please leave a comment on issue #75. PRs are appreciated!

Contributing

If you have an idea, open an issue and let's talk about it, or fork away and send a pull request.

A laundry list of things to take on:

  • Reveal views from Ember, Knockout, Angular, etc.
  • Overlapping boxes are a problem - parent views in real applications will often be obscured by their children.
  • The current scheme for associating a JS constructor with a filepath is messy and can make stack traces ugly.

Worth noting is that I have plans to solidify xray.js into an API and specification that could be used to aid development in any framework - not just Rails and the asset pipeline.

xray-rails's People

Contributors

alenia avatar amatsuda avatar brandondrew avatar brentd avatar cohei avatar dunn avatar flemse avatar fukayatsu avatar hsatac avatar joesteele avatar joshuaflanagan avatar jrmehle avatar kdiogenes avatar mason-stewart avatar mattbrictson avatar mattheworiordan avatar nextekcarl avatar parndt avatar shemerey avatar takitake avatar thenonameguy avatar tricknotes avatar vanessaramirez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xray-rails's Issues

xray breaks Jasmine tests if jasmine-jquery is included

There's a part of code that tries to find jQuery asset on the list and insert xray right after it. Unfortunately, it also matches jasmine-jquery, which happens to be included before jquery itself in my case, so xray loads before jQuery and some things don't work as they should.

I think the regexp should be updated so that it only matches assets that actually start with the asset name after a quote or slash.

Support apps not using the asset pipeline

A lot of future plans for Xray involve the asset pipeline, but the core feature of revealing Rails views/partials does not require it. So with a little work I think Xray could be made compatible.

TODO:

  • Make the Sprockets post/preprocessor registration conditional
  • xray.js and xray.css need to be available to javascript_include_tag and stylesheet_link_tag

@joshuaflanagan started on this in PR #13

Defer loading of Xray JS

Hi guys,

We defer the loading of scripts in our asset pipeline - this is causing Xray to load before jQuery and return an empty object.

On the page, this loads as follows:

Screenshot 2019-06-17 at 12 53 36

Is there a method in place to overcome this?

If not, perhaps something like #98 would work?

Thanks in advance.

Add default rake task for executing RSpec

Right now there isn't an obvious way to run the specs in this project. I'd like to improve that so that a new contributor to the project can get up and running quickly.

Ideally one should be able to run:

bundle exec rake

And that will run all the specs.

Right now I am doing bundle exec rspec, which seems to work. But a default rake task would be more obvious to new devs.

Need ability to disable Xray entirely for a given controller action

Maybe, I'm missing something, but I have view that I need to disable xray on. In the controller, I've passed render xray: false, and it does prevent it from rendering.

I've tried a bunch of combinations. This particular controller action has no other functionality. Here's everything that I've tried:

def show
  render xray: false 
end
def show
  render 'show', xray: false 
end
def show
  respond_to do |format|
    format.html{ render 'show', xray: false }
  end
end

Any thoughts? Is this only not working for me? I've tried it on several different actions and controllers, but it initiates every time.


I'm running Rails 3.2.21 and I just updated to xray-rails 0.1.21. I am also using Turbolinks, but have tried by refreshing the page each time and it still stays enabled.

alias_method_chain is deprecated

As the title already tells, xray-rails is using alias_method_chain to patch ActionView::Template#render but it produces deprecation warnings.

The fix is quite easy but I don't know if you want this as a PR since I just put the module there and it removes compatibility with Ruby <2.0

Let me know what you think :)


DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from <top (required)> at /Volumes/code/_bmonkeys/tomatic/config/environment.rb:5)
	/Users/chaos/.gem/ruby/2.3.0/gems/xray-rails-0.2.0/lib/xray/engine.rb:40:in `block (2 levels) in <class:Engine>'
	/Users/chaos/.gem/ruby/2.3.0/gems/xray-rails-0.2.0/lib/xray/engine.rb:21:in `class_eval'
	/Users/chaos/.gem/ruby/2.3.0/gems/xray-rails-0.2.0/lib/xray/engine.rb:21:in `block in <class:Engine>'

The shortcut doesnot work on chrome/firefox for me anymore.

I have been using x-ray for a while now and all of a sudden it stopped working a couple of days ago. I removed all the browser extensions to make sure nothing is interfering with the gem.

Do you have any insights?

using ruby version 4.2.0

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

  spec.license = 'MIT'
  # or
  spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

Not require config.assets.debug?

Loving this gem! Is there anything we can do to make config.assets.debug = true not be required? We have quite a few CSS/JS files in our app and setting that to false shaves a second or two off our render time in development. Is this so that JS views can be rendered properly? For our project it would be worth the tradeoff.

Would it be possible to configure the engine so we can just manually add a line to application.js to include the xray assets? //= require xray or something similar? Maybe just add the caveat that if you configure your app this way you won't be able to xray JS views?

UPDATE I actually just tried this and it works! So maybe this is just a request to update the documentation to mention this as an option. :)

Thanks!
Rob

How to remove in a rails 4.1 app?

Hi guys,

Trying not to panic here, but I installed xray-rails to check it out. It is broken ( a rails 4.1 app), and I am aware a fix is in the works. In the meantime, I can't get ride of it! I removed it from the gem file, bundle installed it. Deleted cache file sin the browser and the app, reverted to an earlier git repo. Nothing. I have no idea, but somehow the rack middleware is sticking around in a place not covered by the git reversion? I have restarted the app multiple times, nothing. I still get the undefined method `variant' for nil:NilClass error, even after all the above. Thanks......

Can't be used with remote hosts

When the Rails host is not the same as the developer host, there is no way to open the editor by clicking on a template. Cases when this happen are, for example, when the Rails application is run inside Docker or Vagrant.

Ideally, it should use open-in-editor URLs like BetterError or Rails footNotes to open the editor from the client side, instead of from the server side.

undefined method `protocol'

I tried to add xray to my Rails app, but I'm getting an error like this:

undefined method `protocol' for nil:NilClass

actionpack (3.2.12) lib/action_view/asset_paths.rb:88:in `compute_protocol'
actionpack (3.2.12) lib/action_view/asset_paths.rb:73:in `rewrite_host_and_protocol'
actionpack (3.2.12) lib/action_view/asset_paths.rb:29:in `compute_public_path'
actionpack (3.2.12) lib/sprockets/helpers/rails_helper.rb:56:in `asset_path'
actionpack (3.2.12) lib/sprockets/helpers/rails_helper.rb:46:in `block (2 levels) in stylesheet_link_tag'
actionpack (3.2.12) lib/sprockets/helpers/rails_helper.rb:45:in `map'
actionpack (3.2.12) lib/sprockets/helpers/rails_helper.rb:45:in `block in stylesheet_link_tag'
actionpack (3.2.12) lib/sprockets/helpers/rails_helper.rb:43:in `collect'
actionpack (3.2.12) lib/sprockets/helpers/rails_helper.rb:43:in `stylesheet_link_tag'
xray-rails (0.1.5) app/views/_xray_bar.html.erb:43:in `___sers_psionides__rvm_gems_ruby_______p____gems_xray_rails_______app_views__xray_bar_html_erb__2511192901339651191_70159169215940'
...

Do you have any ideas what might be wrong?

xray-rails scripts load before jquery, causing it to break

When using the Teabag jasmine test runner xray-rails loads before jquery, causing to fail. The actual error is: Uncaught TypeError: Object #<Object> has no method 'constructorInfo'. Is there a way to control where the xray script loads so we can avoid this? It looks like the problem is they way the xray script is added, it finds the jasmine-jquery script and inserts itself after that. Unfortunately jquery isn't loaded at that point. Another option for fixing this would be to provide a config option to disable xray for certain paths.

Add possibility to open parent controller(s)

We have a lot of nested and inherited controllers in our app, and most of the time, I'm looking for some functionality in one of the parent controllers.

It would be nice to have a dropdown or something which would offer:

screenshot_16_01_14_12_38-4

Open in rubymine

Hi,

just followed with .xrayconfig:

:editor: 'mine $file'

but it just open the rubymine without file .. Anyone had similar issue ?

Not working well with Rails Engines

Hi there,

first let me say: this project is so great! So helpful for frontend developers, I cannot explain. Many thanks for your effort.

I am trying to use xray-rails in a Rails Engine (3.2.14). It doesn't work out of the box. I had to add xray.jsand xray.cssto application.jsand application.css in of the dummy app in spec/dummy.
What I am missing is the toolbar. It is not showing at the bottom and it also doesn't open sublime text when clicking on one of the boxes. The console shows me a 404.

Hope you can give me a hint on what I am missing.

Cheers,
Can

Middleware generates incorrect path for xray.js

xray-rails not worked with Rails 4.0.1 after update to xray-rails 0.1.7 (and 0.1.8).

I investigate and found that the commit bdad0f4 introduces backward incompatible behavior.

JavaScript include tag generated by 0.1.6 refers to /assets/xray.css and it's correct.

Started GET "/assets/xray.css?body=1" for 127.0.0.1 at 2013-11-15 16:38:07 +0900

But JavaScript include tag generated by 0.1.7 and 0.1.8 refers to /javascripts/xray.js and it's incorrect.

Started GET "/javascripts/xray.js" for 127.0.0.1 at 2013-11-15 16:36:52 +0900
ActionController::RoutingError (No route matches [GET] "/javascripts/xray.js"):

Steps to reproduce: https://gist.github.com/juno/7480622

Any suggestions?

Support .xrayconfig for each rails app.

Currently only ~/.xrayconfig for all projects. If we could put .xrayconfig into each rails app that would be perfect.

For example I use tmux and I'd love to set :editor: "/usr/local/bin/tmux send -t rails_app:editor $'\e' :tabe $file ENTER" as my editor. And I have to modify this file whenever I switch project.

Any1 want this feature as well?

must require xray javascript manually?

I have a Rails 4.2.5.1 app that's already using Jquery, and I stumbled upon this gem today. Added to development group, bundled, removed tmp assets, double checked config.assets.debug was set to true, restarted the app, and tried cmd+shift+x and nothing. Checked console, nothing. Checked html source, found comments for xray wrapping code and figured that's a fallback option for me, but no js file being included on the page.

So I manually required xray in my application.js, reloaded, and I now see the xray message in my console, and the shortcut works! Awesome! Except I can't deploy to heroku like this since it can't find the file to include during precompile phase since I can't tell it to not include that file outside development.

Is there something else I might be missing here? The app doesn't use backbone. It seems like everything is working except the automatic require. As soon as I remove the require, it stops working.

Website broken on IE 6 & 7

Hi,

We use your project in our day to day work and it's very useful but, unfortunately, we have to maintain a browser compatibility to IE 6 and 7. When we check our website on IE6 or iE7 the website is totally broken.

We think the issue comes from the comments added before the doctype. Do you have some idea ?

RuntimeError

Hi, I'm getting a runtime error after adding xray-rails, here's the full trace: https://gist.github.com/mtarnovan/5500721

The culprit is this line in actionpack's rails_helpers.rb
compile_assets? && (Rails.application.config.assets.debug || params[:debug_assets])

After setting Rails.application.config.assets.debug to true, the error went away.

Great idea creating this gem, btw. 👍

Rails 4.1.0 support

Adding following version to Gemfile

gem 'xray-rails', '~> 0.1.12'

Raises the following exception:

undefined method `variant' for nil:NilClass

Xray's comments interfere with ajax interpretation

Our server is returning a snippet of html which jquery is parsing. When xray is turned on, the response looks like this:

<!--XRAY START 118 /Users/yan/dev/reverb/app/views/products/_question.html.erb-->
<li>
<div>some html</div>
</li>
<!--XRAY END 118-->

It seems this causes an error in jquery 1.8 and possibly later versions while parsing the XHR response:

Uncaught TypeError: Cannot use 'in' operator to search for 'backgroundColor' in undefined 

I'm not sure what to do about it yet, but if we figure it out, we'll submit a pull request.

v0.1.17 can't load lib/xray/middleware

Downgrading to v0.1.16 fixes this:

/usr/local/rvm/gems/ruby-2.1.2@my_app/gems/xray-rails-0.1.17/lib/xray-rails.rb:5:in `require_relative': cannot load such file -- /usr/local/rvm/gems/ruby-2.1.2@my_app/gems/xray-rails-0.1.17/lib/xray/middleware (LoadError)
    from /usr/local/rvm/gems/ruby-2.1.2@my_app/gems/xray-rails-0.1.17/lib/xray-rails.rb:5:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `require'
    from /usr/local/rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /usr/local/rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `each'
    from /usr/local/rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `block in require'
    from /usr/local/rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `each'
    from /usr/local/rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `require'
    from /usr/local/rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler.rb:132:in `require'
    from /var/www/my_app/releases/20151020220531/config/application.rb:12:in `<top (required)>'
    from /var/www/my_app/releases/20151020220531/config/environment.rb:2:in `require'
    from /var/www/my_app/releases/20151020220531/config/environment.rb:2:in `<top (required)>'
    from config.ru:4:in `require'
    from config.ru:4:in `block in <main>'
    from /usr/local/rvm/gems/ruby-2.1.2@my_app/gems/rack-1.5.5/lib/rack/builder.rb:55:in `instance_eval'
    from /usr/local/rvm/gems/ruby-2.1.2@my_app/gems/rack-1.5.5/lib/rack/builder.rb:55:in `initialize'
    from config.ru:1:in `new'
    from config.ru:1:in `<main>'
    from /usr/local/rvm/gems/ruby-2.1.2@my_app/gems/unicorn-4.9.0/lib/unicorn.rb:48:in `eval'
    from /usr/local/rvm/gems/ruby-2.1.2@my_app/gems/unicorn-4.9.0/lib/unicorn.rb:48:in `block in builder'
    from /usr/local/rvm/gems/ruby-2.1.2@my_app/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:768:in `call'
    from /usr/local/rvm/gems/ruby-2.1.2@my_app/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:768:in `build_app!'
    from /usr/local/rvm/gems/ruby-2.1.2@my_app/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:632:in `init_worker_process'
    from /usr/local/rvm/gems/ruby-2.1.2@my_app/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:655:in `worker_loop'
    from /usr/local/rvm/gems/ruby-2.1.2@my_app/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:529:in `spawn_missing_workers'
    from /usr/local/rvm/gems/ruby-2.1.2@my_app/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:540:in `maintain_worker_count'
    from /usr/local/rvm/gems/ruby-2.1.2@my_app/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:294:in `join'
    from /usr/local/rvm/gems/ruby-2.1.2@my_app/gems/unicorn-4.9.0/bin/unicorn:126:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.1.2@my_app/bin/unicorn:23:in `load'
    from /usr/local/rvm/gems/ruby-2.1.2@my_app/bin/unicorn:23:in `<main>'
    from /usr/local/rvm/gems/ruby-2.1.2@my_app/bin/ruby_executable_hooks:15:in `eval'
    from /usr/local/rvm/gems/ruby-2.1.2@my_app/bin/ruby_executable_hooks:15:in `<main>'

atom editor not working

Hello,

With subl everything works well. But I can't seem to make it work with atom.

I tried putting:

EDITOR = '/usr/local/bin/atom'

in my .env file, nothing happens when clicked.

Exact same behavior when I use ~/.xrayconfig with:

:editor: '/usr/local/bin/atom'

Any ideas ?

Conflict with modal dialogs in Chrome

I'm not certain what's causing the problem, but I'd be happy to help debug. Without xray-rails, a modal dialog provided by easyModal works as expected. With xray-rails, and using Chrome, the shroud overlays the modal and prevents interaction with underlying buttons. Clicking anywhere dismisses the modal.

example1

Everything works as expected in Firefox.

example2

My team has suggested it might be an issue with z-order. Possibly related to #22 and #24.

commands don't work!

First of all, great job!
I've installed the gem and did the bundle for my Rails app. I check that xray-rails gem is working but when I apply cmd+shift+x it doesn't work.
I've modified the commands (cmd+shift+x) to (cmd+shift+c) and it works (xray-rails paints my partials) so I notice that when I press cmd+shift, when I try to press x it doesn't work.
Can I suggest to apply changes in order to custom de commands?
Could anyone tell me what is not working it well?

Thank you!

Sprockets::Rails::Helper::AssetFilteredError

In latest rails you have to edit assets.rb, not a big deal but still. Would be great if this could be circumvented somehow.

Asset filtered out and will not be served: add `Rails.application.config.assets.precompile += %w( xray-backbone.js )` to `config/initializers/assets.rb` and restart your server

0.1.20 breaks backwards compatibility with Rails 3.2

As pointed out by @nnc:


response.header['Content-Length'] = content_length unless response.try(:committed?)

this line raises the error below on Rails 3.2. It seems ActionDispatch::Response#committed? was added in Rails 4.0.

NoMethodError - undefined method `committed?' for #<ActionDispatch::Response:0x007f92c2ecedf0>:
  activesupport (3.2.22.2) lib/active_support/core_ext/object/try.rb:36:in `try'
  xray-rails (0.1.20) lib/xray/middleware.rb:62:in `call'

Just guarding against it with unless response.respond_to?(:committed?) && response.committed? seems to solve this issue for me, but I'm not at all familiar with this code base and don't really know what I'm doing, so can you please take another look at this?

Thanks

calling non-existent method 'pathname'

After installing, my app failed to regenerate assets, with errors such as

undefined method `pathname' for #<#<Class:0x00000039790f2ca8>:0x00000039779e5b28>

As far as I understand, the context provided by sprockets no longer has a pathname method. Replacing the first line of the self.run method in xray/engine.rb to read

path = Pathname.new(context.filename).to_s

solved the problem for me (but I don't really understand what's going on there)

Enumerator object for CSV streaming will be iterated through twice instead of just once

Environment:

  • Ruby 2.0.0-p247
  • Rails 3.2.13
  • xray-rails 0.1.6

Use the following steps to reproduce:

If the CSV is big, noticeable delay happens in the Rails controller. It's a minor problem b/c normally you would not turn on Xray in production. But the application data could be incorrect in development b/c of the side-effect that the Enumerator has been called twice. The enumerator shown in the vanilla Rails app is defined on line app/controllers/csv_controller.rb#18.

Cause:

  • The first time the enumerator is invoked during the Xray middleware steps. The call !response.respond_to?(:body) on line xray-rails-0.1.6/lib/xray/middleware.rb:80 . The call invokes respond_to? on line actionpack-3.2.13/lib/action_dispatch/http/response.rb:115, which triggers the each block on line action_dispatch/http/response.rb:115. Eventually it iterates through the Enumerator object defined in the Rails controller, i.e. CsvController#index. The second time the enumerator is invoked when the CSV is rendered/downloaded.

Possible fix:

  • Switch the order of the following 2 lines in middleware.rb, method should_inject_xray?,
      !empty?(response) &&
      html_request?(headers, response) &&
  • Or not use respond_to? on this line xray-rails-0.1.6/lib/xray/middleware.rb:80.

Xray causes Yield to be empty

Hi,
In our application (big business application) we have the problem, that for on of our pages the sidebar
which is included in the view with = yield :sidebar is not rendered.
The only special thing about that page is, that the yield is filled from a gem (so the content_for :sidebar calls are done in a separate gem).
As soon as we remove xray-rails it works fine. Has anyone encountered a similar problem? And might be able to point me in the correct direction?
Thanks!

Two partials that lay 1:1 over each other doesn't allow to select the overlaying partial

We have a _fields.html.haml partial that is visually laying 1:1 above a _form.html.haml partial (this means they both have exactly the same dimensions and position).

The problem here is that xray-rails doesn't allow to click on the _fields.html.haml partial. Take a look at my screenshot: I'm hovering in the Chrome Inspector over the _fields partial, but it's not visible on the site (it's under _form).

image

I'd would be great if this would be fixed somehow. Thank you.

xray-rails fails to initialize after upgrading to sprockets-rails 3.0.0

The 3.0.0 version of sprockets-rails was just released. Unfortunately, as I write this there is no changelog or release notes, so it is hard to say exactly what is different. However, a Rails 4.2.5 app with sprockets-rails 3.0.0 and xray-rails now fails to load:

xray-rails requires the Rails asset pipeline.
The asset pipeline is currently disabled in this application.
Either convert your application to use the asset pipeline, or remove xray-rails from your Gemfile.
xray-rails-0.1.17/lib/xray/engine.rb:10:in `block in <class:Engine>

xray-rails is not compatible with Rails 5 beta?

I get an error after the latest version of xray is added to a Rails 5 project.

NoMethodError - undefined method `clean' for #<Hash:0x007f99b1576410>
Did you mean?  clear:
  actionpack (5.0.0.beta1) lib/action_dispatch/middleware/exception_wrapper.rb:118:in `clean_backtrace'
  actionpack (5.0.0.beta1) lib/action_dispatch/middleware/exception_wrapper.rb:52:in `application_trace'
  meta_request (0.3.4) lib/meta_request/event.rb:19:in `events_for_exception'
  meta_request (0.3.4) lib/meta_request/middlewares/app_request_handler.rb:17:in `rescue in call'
  meta_request (0.3.4) lib/meta_request/middlewares/app_request_handler.rb:24:in `call'
  meta_request (0.3.4) lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
  actionview (5.0.0.beta1) lib/action_view/digestor.rb:14:in `call'
  rack (2.0.0.alpha) lib/rack/etag.rb:25:in `call'
  rack (2.0.0.alpha) lib/rack/conditional_get.rb:25:in `call'
  rack (2.0.0.alpha) lib/rack/head.rb:12:in `call'
  rack (2.0.0.alpha) lib/rack/session/abstract/id.rb:220:in `context'
  rack (2.0.0.alpha) lib/rack/session/abstract/id.rb:214:in `call'
  actionpack (5.0.0.beta1) lib/action_dispatch/middleware/cookies.rb:608:in `call'
  activerecord (5.0.0.beta1) lib/active_record/query_cache.rb:36:in `call'
  activerecord (5.0.0.beta1) lib/active_record/connection_adapters/abstract/connection_pool.rb:963:in `call'
  activerecord (5.0.0.beta1) lib/active_record/migration.rb:524:in `call'
  actionpack (5.0.0.beta1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (5.0.0.beta1) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
  activesupport (5.0.0.beta1) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
  activesupport (5.0.0.beta1) lib/active_support/callbacks.rb:90:in `run_callbacks'
  actionpack (5.0.0.beta1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (5.0.0.beta1) lib/action_dispatch/middleware/reloader.rb:71:in `call'
  actionpack (5.0.0.beta1) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
  rack-contrib (1.2.0) lib/rack/contrib/response_headers.rb:17:in `call'
  meta_request (0.3.4) lib/meta_request/middlewares/headers.rb:16:in `call'
  actionpack (5.0.0.beta1) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
  web-console (3.0.0) lib/web_console/middleware.rb:27:in `call'
  actionpack (5.0.0.beta1) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
  railties (5.0.0.beta1) lib/rails/rack/logger.rb:42:in `call_app'
  railties (5.0.0.beta1) lib/rails/rack/logger.rb:24:in `block in call'
  activesupport (5.0.0.beta1) lib/active_support/tagged_logging.rb:70:in `block in tagged'
  activesupport (5.0.0.beta1) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (5.0.0.beta1) lib/active_support/tagged_logging.rb:70:in `tagged'
  railties (5.0.0.beta1) lib/rails/rack/logger.rb:24:in `call'
  actionpack (5.0.0.beta1) lib/action_dispatch/middleware/request_id.rb:24:in `call'
  rack (2.0.0.alpha) lib/rack/method_override.rb:22:in `call'
  rack (2.0.0.alpha) lib/rack/runtime.rb:22:in `call'
  activesupport (5.0.0.beta1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  actionpack (5.0.0.beta1) lib/action_dispatch/middleware/load_interlock.rb:13:in `call'
  actionpack (5.0.0.beta1) lib/action_dispatch/middleware/static.rb:132:in `call'
  rack (2.0.0.alpha) lib/rack/sendfile.rb:111:in `call'
  railties (5.0.0.beta1) lib/rails/engine.rb:522:in `call'
  puma (2.15.3) lib/puma/server.rb:541:in `handle_request'
  puma (2.15.3) lib/puma/server.rb:388:in `process_client'
  puma (2.15.3) lib/puma/server.rb:270:in `block in run'
  puma (2.15.3) lib/puma/thread_pool.rb:106:in `block in spawn_thread'

Any advise?
Thanks.

ruby 1.8 compatibility

On attempt to run:

gems/xray-rails-0.1.5/lib/xray-rails.rb:61: odd number list for Hash (SyntaxError)
      info = {name: class_name, path: path.to_s}
gems/xray-rails-0.1.5/lib/xray-rails.rb:61: syntax error, unexpected ':', expecting '}'
      info = {name: class_name, path: path.to_s}
gems/xray-rails-0.1.5/lib/xray-rails.rb:61: syntax error, unexpected ':', expecting '='
      info = {name: class_name, path: path.to_s}
                                     ^

Switch from decorating templates with HTML comments

I've noticed the HTML comments that Xray injects cause a couple issues.

  • #22 - though I can't seem to reproduce it, I've heard from a couple folks that they mess with jQuery when in an XHR response body.
  • When handing Bootstrap's modal JS a template with Xray's HTML comments, it causes weird bugs like multiple backdrops.

The Bootstrap issue doesn't really have anything to do with the HTML comments per se; more that the JS doesn't expect to be given a jQuery object with anything other than a single root node. However I'm feeling that injecting extra DOM nodes in general could be prone to problems like this.

One idea would be to add data-xray attributes to DOM nodes instead. For example:

In a partial with one root node:

<div class="my-modal" data-xray="/path/to/file">
   ...
</div>

In a partial with multiple root nodes:

<div class="my-modal" data-xray="/path/to/file" data-xray-id="12">
   ...
</div>
<span>Cool span bro!</span>
<div class="other-div" data-xray-id="12">
   ...
</div>

In this example, data-xray-id is used to link the two outer sibling roots of the template together.

The main drawback of this proposal is that wrapping a template with HTML comments is simple; manipulating HTML attributes is not (imagine if the template starts with a weird node like a comment, or a doctype, or a script tag, etc). Really don't want to drag an XML parser into xray's dependencies.

Getting xray-rails to work with Sublime Text 3

I've been having trouble getting xray-rails to open files using Sublime Text 3.

I have my ``~/.xrayconfig` file defined as follows:


---
:editor: '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'

I'm not sure why it won't open files as I can open files with Sublime from the command line by running the following command:
'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl' name_of_file

I'm pretty baffled on why it won't work with xray-rails. The only other piece of relevant information that I can think of is that I have oh-my-zsh installed on my machine.

Any ideas on how to get this to work or what I could be doing wrong?

Thanks a lot.

"require: false" option

It would be nice to have documentation on how to use xray-rails with the require: false option in the Gemfile. On initial pass I tried using an environment variable to specify whether or not to require xray-rails at the top of my development.rb, but that didn't seem to do it. Works perfectly in Rails 4.1 and FF by requiring it in the Gemfile.

It look like xray works by using a Rails engine. I'm not too keen on how engines work. I'm assuming there's some dynamic lookup for ancestors on app load?

Early return from partial causes undefined method `include?' for nil:NilClass

Early returning from a partial in this manner:

../index.html.haml

   %div
      = render partial: 'shared/component'

shared/_component.html.haml

- return unless current_user.name.presence
%div= current_user.name.humanize

causes this error:
NoMethodError at /
undefined method 'include?' for nil:NilClass

I'm on version xray-rails (0.1.21)

Skip xray for email templates

XRay adds its comments into mailers templates (html/text whatever). It get little messy when I try tests my emails generated in development environment against SPAM test and other, because it's complaining about this comments. It it also impossible to inspect emails by XRay, so why these comments should even be there?

Turbolinks causes UI Bar to disappear

I use turbolinks in one of my projects and I noticed that when you change the page xray keep working but the control bar at the bottom is gone.

It is not a big deal since I can simply refresh the page but maybe it's an easy fix.

Best
Sven

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.