1 - Look at source code for the current bundle gem version¶ ↑
$ bundle open <gem name>;
Ctl-O = Return back to Netrw dir listing
2 - Get recursive list of dependent gem versions¶ ↑
$ gem lock rails-3.2.13;
2a - Generate PNG of gem dependencies in Gemfile¶ ↑
$ bundle viz;
3 - Rails console¶ ↑
Get nice output in console (YAML output of last command)
> y _
Find exact location of a method
> method(:app).source_location => ["/Users/doug/.rvm/gems/ruby-2.2.1/gems/railties-4.2.1/lib/rails/console/app.rb", 8] > app.method(:get).source_location => ["/Users/doug/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.1/lib/action_dispatch/testing/integration.rb", 31]
'app' method gives you an integration session instance, so you can use it just like when you’re a normal integration test for Rails.
> app.class => ActionDispatch::Integration::Session
Get list of methods associated with asset pipeline
> Rails.application.methods.each do |method| puts method if method =~ /asset/ end;nil
Get asset file contents
https://github.com/sstephenson/sprockets 'find_asset' method (aliased as []) to retrieve an asset from a Sprockets environment. > Rails.application.assets.class => Sprockets::Environment Pass it a logical path and you'll get a Sprockets::BundledAsset (Call 'to_s' on the resulting asset to access its contents) > Rails.application.assets['spree/frontend/product.js'].to_s
4 - Run functional tests for only 1 controller¶ ↑
ruby -I test test/functional/globes_controller_test.rb;
(The '-I test' adds the test env into the ruby $LOAD_PATH)
5 - Put <% debugger %> tags in '.erb' code¶ ↑
(rdb) info variables (rdb:1) bt If you are in a View and want to see whole callstack, including the Controller, then DELIBERATELY PUT INCORRECT OBJECT NAME in 'erb'