SlideShare a Scribd company logo
Code Diving in Ruby
Evan Dorn
Founder, Logical Reality Design
http://lrdesign.com
evan@lrdesign.com
@idahoev
Friday, August 9, 13
SO YOU’RE CODING
ALONG WHEN...
Friday, August 9, 13
1) InvoicesController as an admin GET index should paginate all unpaid invoices as
@unpaid_invoices
Failure/Error: get :index
NoMethodError:
undefined method `unpayed' for #<Class:0x007fd8cfe9ee18>
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activerecord-3.2.12/lib/active_record/dynamic_matchers.rb:55:in `method_missing'
# ./app/controllers/invoices_controller.rb:7:in `index'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/abstract_controller/base.rb:167:in `process_action'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/action_controller/metal/rendering.rb:10:in `process_action'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activesupport-3.2.12/lib/active_support/callbacks.rb:447:in
`_run__3859364058582123788__process_action__4176185741589430016__callbacks'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activesupport-3.2.12/lib/active_support/callbacks.rb:385:in
`_run_process_action_callbacks'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/abstract_controller/callbacks.rb:17:in `process_action'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/action_controller/metal/rescue.rb:29:in `process_action'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:30:in `block in
process_action'
Friday, August 9, 13
AND YOU’RE LIKE
Friday, August 9, 13
BUT THEN YOU NOTICE
THIS...
Friday, August 9, 13
1) InvoicesController as an admin GET index should paginate all unpaid invoices as
@unpaid_invoices
Failure/Error: get :index
NoMethodError:
undefined method `unpayed' for #<Class:0x007fd8cfe9ee18>
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activerecord-3.2.12/lib/active_record/dynamic_matchers.rb:55:in `method_missing'
# ./app/controllers/invoices_controller.rb:7:in `index'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/abstract_controller/base.rb:167:in `process_action'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/action_controller/metal/rendering.rb:10:in `process_action'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activesupport-3.2.12/lib/active_support/callbacks.rb:447:in
`_run__3859364058582123788__process_action__4176185741589430016__callbacks'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activesupport-3.2.12/lib/active_support/callbacks.rb:385:in
`_run_process_action_callbacks'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/abstract_controller/callbacks.rb:17:in `process_action'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/action_controller/metal/rescue.rb:29:in `process_action'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:30:in `block in
process_action'
Friday, August 9, 13
1) InvoicesController as an admin GET index should paginate all unpaid invoices as
@unpaid_invoices
Failure/Error: get :index
NoMethodError:
undefined method `unpayed' for #<Class:0x007fd8cfe9ee18>
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activerecord-3.2.12/lib/active_record/dynamic_matchers.rb:55:in `method_missing'
# ./app/controllers/invoices_controller.rb:7:in `index'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/abstract_controller/base.rb:167:in `process_action'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/action_controller/metal/rendering.rb:10:in `process_action'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activesupport-3.2.12/lib/active_support/callbacks.rb:447:in
`_run__3859364058582123788__process_action__4176185741589430016__callbacks'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activesupport-3.2.12/lib/active_support/callbacks.rb:385:in
`_run_process_action_callbacks'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/abstract_controller/callbacks.rb:17:in `process_action'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/action_controller/metal/rescue.rb:29:in `process_action'
# /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:30:in `block in
process_action'
Friday, August 9, 13
BUT WHAT ABOUT
WHEN...
Friday, August 9, 13
/Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/active_support/
core_ext/hash/keys.rb:25:in `symbolize_keys': You blew it, dumbass (RuntimeError)
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/connection_adapters/abstract/connection_specification.rb:45:in `resolve_hash_connection'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:26:in `block in on_load'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:25:in `each'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:25:in `on_load'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/railtie.rb:74:in `block in <class:Railtie>'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:30:in `instance_exec'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:30:in `run'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:55:in `block in run_initializers'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:54:in `each'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:54:in `run_initializers'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
application.rb:136:in `initialize!'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
railtie/configurable.rb:30:in `method_missing'
from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/config/environment.rb:5:in `<top
(required)>'
from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/spec/spec_helper.rb:3:in `require'
from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/spec/spec_helper.rb:3:in `<top
Friday, August 9, 13
/Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/active_support/
core_ext/hash/keys.rb:25:in `symbolize_keys': You blew it, dumbass (RuntimeError)
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/connection_adapters/abstract/connection_specification.rb:45:in `resolve_hash_connection'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:26:in `block in on_load'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:25:in `each'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:25:in `on_load'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/railtie.rb:74:in `block in <class:Railtie>'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:30:in `instance_exec'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:30:in `run'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:55:in `block in run_initializers'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:54:in `each'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:54:in `run_initializers'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
application.rb:136:in `initialize!'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
railtie/configurable.rb:30:in `method_missing'
from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/config/environment.rb:5:in `<top
(required)>'
from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/spec/spec_helper.rb:3:in `require'
from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/spec/spec_helper.rb:3:in `<top
Friday, August 9, 13
/Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/active_support/
core_ext/hash/keys.rb:25:in `symbolize_keys': You blew it, dumbass (RuntimeError)
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/connection_adapters/abstract/connection_specification.rb:45:in `resolve_hash_connection'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:26:in `block in on_load'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:25:in `each'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:25:in `on_load'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/railtie.rb:74:in `block in <class:Railtie>'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:30:in `instance_exec'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:30:in `run'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:55:in `block in run_initializers'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:54:in `each'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:54:in `run_initializers'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
application.rb:136:in `initialize!'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
railtie/configurable.rb:30:in `method_missing'
from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/config/environment.rb:5:in `<top
(required)>'
from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/spec/spec_helper.rb:3:in `require'
from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/spec/spec_helper.rb:3:in `<top
Friday, August 9, 13
/Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/active_support/
core_ext/hash/keys.rb:25:in `symbolize_keys': You blew it, dumbass (RuntimeError)
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/connection_adapters/abstract/connection_specification.rb:45:in `resolve_hash_connection'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:26:in `block in on_load'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:25:in `each'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/
active_support/lazy_load_hooks.rb:25:in `on_load'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/
active_record/railtie.rb:74:in `block in <class:Railtie>'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:30:in `instance_exec'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:30:in `run'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:55:in `block in run_initializers'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:54:in `each'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
initializable.rb:54:in `run_initializers'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
application.rb:136:in `initialize!'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/
railtie/configurable.rb:30:in `method_missing'
from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/config/environment.rb:5:in `<top
(required)>'
from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/spec/spec_helper.rb:3:in `require'
from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/spec/spec_helper.rb:3:in `<top
Friday, August 9, 13
IT’S PROBABLY
SOMETHING YOU DID.
Friday, August 9, 13
IT’S PROBABLY
SOMETHING YOU DID.
(but the error’s not in
your code)
Friday, August 9, 13
RAILS’ CODE IS
HARD TO UNDERSTAND
Friday, August 9, 13
RAILS’ CODE IS
HARD TO UNDERSTAND
But that doesn’t matter!
Dive in anyway.
Friday, August 9, 13
RUBY IS A RUN-TIME
LANGUAGE
Friday, August 9, 13
RUBY IS A RUN-TIME
LANGUAGE
•This makes it hard to find stuff!
Friday, August 9, 13
RUBY IS A RUN-TIME
LANGUAGE
•This makes it hard to find stuff!
•Your IDE isn’t much help
Friday, August 9, 13
RUBY IS A RUN-TIME
LANGUAGE
•This makes it hard to find stuff!
•Your IDE isn’t much help
•So find stuff AT RUN TIME
Friday, August 9, 13
JUST OPEN THAT FILE
Friday, August 9, 13
JUST OPEN THAT FILE
Don’t be intimidated ... it’s all just Ruby
Friday, August 9, 13
JUST OPEN THAT FILE
~/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/active_support/
core_ext/hash/keys.rb:25:in `symbolize_keys': You blew it, dumbass (RuntimeError)
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activerecord-3.2.12/lib/active_record/connection_adapters/abstract/
connection_specification.rb:45:in `resolve_hash_connection'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activerecord-3.2.12/lib/active_record/connection_adapters/abstract/
connection_specification.rb:41:in `resolve_string_connection'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
Don’t be intimidated ... it’s all just Ruby
Friday, August 9, 13
JUST OPEN THAT FILE
~/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/active_support/
core_ext/hash/keys.rb:25:in `symbolize_keys': You blew it, dumbass (RuntimeError)
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activerecord-3.2.12/lib/active_record/connection_adapters/abstract/
connection_specification.rb:45:in `resolve_hash_connection'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
activerecord-3.2.12/lib/active_record/connection_adapters/abstract/
connection_specification.rb:41:in `resolve_string_connection'
from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
$ vim ~evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12
Don’t be intimidated ... it’s all just Ruby
Friday, August 9, 13
USE GEM...
Friday, August 9, 13
USE GEM...
$ gem env
Friday, August 9, 13
USE GEM...
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.25
- RUBY VERSION: 1.9.3 (2012-11-10 patchlevel 327) [x86_64-darwin11.4.2]
- INSTALLATION DIRECTORY: /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fas
- RUBY EXECUTABLE: /Volumes/Valinor/Users/evan/.rvm/rubies/ruby-1.9.3-p327-fast/bin/
- EXECUTABLE DIRECTORY: /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-
fast@tracks/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-11
- GEM PATHS:
- /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks
- /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@global
- GEM CONFIGURATION:
$ gem env
Friday, August 9, 13
USE GEM...
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.25
- RUBY VERSION: 1.9.3 (2012-11-10 patchlevel 327) [x86_64-darwin11.4.2]
- INSTALLATION DIRECTORY: /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fas
- RUBY EXECUTABLE: /Volumes/Valinor/Users/evan/.rvm/rubies/ruby-1.9.3-p327-fast/bin/
- EXECUTABLE DIRECTORY: /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-
fast@tracks/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-11
- GEM PATHS:
- /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks
- /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@global
- GEM CONFIGURATION:
$ gem env
Friday, August 9, 13
USE GEM...
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.25
- RUBY VERSION: 1.9.3 (2012-11-10 patchlevel 327) [x86_64-darwin11.4.2]
- INSTALLATION DIRECTORY: /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fas
- RUBY EXECUTABLE: /Volumes/Valinor/Users/evan/.rvm/rubies/ruby-1.9.3-p327-fast/bin/
- EXECUTABLE DIRECTORY: /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-
fast@tracks/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-11
- GEM PATHS:
- /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks
- /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@global
- GEM CONFIGURATION:
$ gem env
$ cd /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks
Friday, August 9, 13
ASK RUBY YOUR
QUESTIONS!
Friday, August 9, 13
WHAT’S THIS VALUE?
#activesupport-3.2.12/lib/active_support/core_ext/hash
class Hash
# Return a new hash with all keys converted to symbols, as
# long as they respond to +to_sym+.
#
# { 'name' => 'Rob', 'years' => '28' }.symbolize_keys
# #=> { :name => "Rob", :years => "28" }
def symbolize_keys
dup.symbolize_keys!
end
alias_method :to_options, :symbolize_keys
alias_method :to_options!, :symbolize_keys!
# Validate all keys in a hash match *valid keys, raising
ArgumentError on a mismatch.
# Note that keys are NOT treated indifferently, meaning if you
use strings for keys but assert symbols
Friday, August 9, 13
WHAT’S THIS VALUE?
#activesupport-3.2.12/lib/active_support/core_ext/hash
class Hash
# Return a new hash with all keys converted to symbols, as
# long as they respond to +to_sym+.
#
# { 'name' => 'Rob', 'years' => '28' }.symbolize_keys
# #=> { :name => "Rob", :years => "28" }
def symbolize_keys
dup.symbolize_keys!
end
alias_method :to_options, :symbolize_keys
alias_method :to_options!, :symbolize_keys!
# Validate all keys in a hash match *valid keys, raising
ArgumentError on a mismatch.
# Note that keys are NOT treated indifferently, meaning if you
use strings for keys but assert symbols
Friday, August 9, 13
WHAT’S THIS VALUE?
#activesupport-3.2.12/lib/active_support/core_ext/hash
class Hash
# Return a new hash with all keys converted to symbols, as
# long as they respond to +to_sym+.
#
# { 'name' => 'Rob', 'years' => '28' }.symbolize_keys
# #=> { :name => "Rob", :years => "28" }
def symbolize_keys
p self
dup.symbolize_keys!
end
alias_method :to_options, :symbolize_keys
alias_method :to_options!, :symbolize_keys!
# Validate all keys in a hash match *valid keys, raising
ArgumentError on a mismatch.
# Note that keys are NOT treated indifferently, meaning if you
Friday, August 9, 13
TOO MUCH OUTPUT!
.{:client_id=>"24"}
{"controller"=>"invoices", "action"=>"new"}
.{:client_id=>"27"}
{"controller"=>"invoices", "action"=>"new"}
.{:client_id=>"30"}
{"controller"=>"invoices", "action"=>"new"}
.{:client_id=>"33"}
{"controller"=>"invoices", "action"=>"new"}
.{:client_id=>"37"}
{"controller"=>"invoices", "action"=>"new"}
.{:id=>"19"}
{"id"=>"19", "controller"=>"invoices", "action"=>"edit"}
.{:id=>"20"}
{"id"=>"20", "controller"=>"invoices", "action"=>"edit"}
{:controller=>"devise/
sessions", :action=>"new", :use_route=>"login", :only_path=>true}
.
{:invoice=>{:due_on=>"2013-05-14", :client_id=>"42",
:notes=>"value for notes"}}
Friday, August 9, 13
OUTPUT AND STOP
#activesupport-3.2.12/lib/active_support/core_ext/hash
class Hash
# Return a new hash with all keys converted to symbols, as
# long as they respond to +to_sym+.
#
# { 'name' => 'Rob', 'years' => '28' }.symbolize_keys
# #=> { :name => "Rob", :years => "28" }
def symbolize_keys
raise self # stop running!
dup.symbolize_keys!
end
alias_method :to_options, :symbolize_keys
alias_method :to_options!, :symbolize_keys!
# Validate all keys in a hash match *valid keys, raising
ArgumentError on a mismatch.
# Note that keys are NOT treated indifferently, meaning if you
Friday, August 9, 13
ADD A CONDITION
#activesupport-3.2.12/lib/active_support/core_ext/hash
class Hash
# Return a new hash with all keys converted to symbols, as
# long as they respond to +to_sym+.
#
# { 'name' => 'Rob', 'years' => '28' }.symbolize_keys
# #=> { :name => "Rob", :years => "28" }
def symbolize_keys
raise self if <some condition>
dup.symbolize_keys!
end
alias_method :to_options, :symbolize_keys
alias_method :to_options!, :symbolize_keys!
# Validate all keys in a hash match *valid keys, raising
ArgumentError on a mismatch.
# Note that keys are NOT treated indifferently, meaning if you
Friday, August 9, 13
KEEP TRACK OF LOCATION
#activesupport-3.2.12/lib/active_support/core_ext/hash
class Hash
# Return a new hash with all keys converted to symbols, as
# long as they respond to +to_sym+.
#
# { 'name' => 'Rob', 'years' => '28' }.symbolize_keys
# #=> { :name => "Rob", :years => "28" }
def symbolize_keys
p __FILE__, __LINE__
dup.symbolize_keys!
end
alias_method :to_options, :symbolize_keys
alias_method :to_options!, :symbolize_keys!
# Validate all keys in a hash match *valid keys, raising
ArgumentError on a mismatch.
# Note that keys are NOT treated indifferently, meaning if you
Friday, August 9, 13
LABEL WITH LOCATION
#activesupport-3.2.12/lib/active_support/core_ext/hash
class Hash
# Return a new hash with all keys converted to symbols, as
# long as they respond to +to_sym+.
#
# { 'name' => 'Rob', 'years' => '28' }.symbolize_keys
# #=> { :name => "Rob", :years => "28" }
def symbolize_keys
p “#{__FILE__}:#{__LINE__}” => self
dup.symbolize_keys!
end
alias_method :to_options, :symbolize_keys
alias_method :to_options!, :symbolize_keys!
# Validate all keys in a hash match *valid keys, raising
ArgumentError on a mismatch.
# Note that keys are NOT treated indifferently, meaning if you
Friday, August 9, 13
TAG WITH A NAME
#activesupport-3.2.12/lib/active_support/core_ext/hash
class Hash
# Return a new hash with all keys converted to symbols, as
# long as they respond to +to_sym+.
#
# { 'name' => 'Rob', 'years' => '28' }.symbolize_keys
# #=> { :name => "Rob", :years => "28" }
def symbolize_keys
p :broken_hash => self
dup.symbolize_keys!
end
alias_method :to_options, :symbolize_keys
alias_method :to_options!, :symbolize_keys!
# Validate all keys in a hash match *valid keys, raising
ArgumentError on a mismatch.
# Note that keys are NOT treated indifferently, meaning if you
Friday, August 9, 13
CLEAN IT UP
#activesupport-3.2.12/lib/active_support/core_ext/hash
class Hash
# Return a new hash with all keys converted to symbols, as
# long as they respond to +to_sym+.
#
# { 'name' => 'Rob', 'years' => '28' }.symbolize_keys
# #=> { :name => "Rob", :years => "28" }
def symbolize_keys
require ‘pp’
pp self
dup.symbolize_keys!
end
alias_method :to_options, :symbolize_keys
alias_method :to_options!, :symbolize_keys!
# Validate all keys in a hash match *valid keys, raising
ArgumentError on a mismatch.
Friday, August 9, 13
OTHER USEFUL
QUESTIONS
Friday, August 9, 13
HOW DID I GET HERE?
Friday, August 9, 13
HOW DID I GET HERE?
#activesupport-3.2.12/lib/active_support/core_ext/hash
class Hash
# Return a new hash with all keys converted to symbols, as
# long as they respond to +to_sym+.
#
# { 'name' => 'Rob', 'years' => '28' }.symbolize_keys
# #=> { :name => "Rob", :years => "28" }
def symbolize_keys
require ‘pp’
pp caller[0..10]
dup.symbolize_keys!
end
alias_method :to_options, :symbolize_keys
alias_method :to_options!, :symbolize_keys!
# Validate all keys in a hash match *valid keys, raising
ArgumentError on a mismatch.
Friday, August 9, 13
“DOES THIS FILE LOAD?”
module SomePossiblyIncludedMonkeyPatch
def change_important_class_behavior
# ...
# ...
end
def obscure_some_key_method
# ...
# ...
end
end
Friday, August 9, 13
“DOES THIS FILE LOAD?”
raise “Yes, somebody required me”
module SomePossiblyIncludedMonkeyPatch
def change_important_class_behavior
# ...
# ...
end
def obscure_some_key_method
# ...
# ...
end
end
Friday, August 9, 13
“WHY DIDN’T THIS FILE LOAD?”
Friday, August 9, 13
“WHY DIDN’T THIS FILE LOAD?”
require ‘some_library/some_junk’
module MyNiftyBehavior
def stuff
Friday, August 9, 13
“WHY DIDN’T THIS FILE LOAD?”
require ‘some_library/some_junk’
module MyNiftyBehavior
def stuff
$ rspec spec/
No such file to load -- some_library/some_junk (LoadError)
Friday, August 9, 13
“WHY DIDN’T THIS FILE LOAD?”
require ‘some_library/some_junk’
module MyNiftyBehavior
def stuff
$ rspec spec/
No such file to load -- some_library/some_junk (LoadError)
... pretty print the search path
Friday, August 9, 13
“WHY DIDN’T THIS FILE LOAD?”
require ‘some_library/some_junk’
module MyNiftyBehavior
def stuff
$ rspec spec/
No such file to load -- some_library/some_junk (LoadError)
... pretty print the search path
require ‘pp’
pp $:
require ‘some_library/some_junk’
module MyNiftyBehavior
def stuff
Friday, August 9, 13
“WHO REQUIRED ME?”
module SomePossiblyIncludedMonkeyPatch
def change_important_class_behavior
# ...
# ...
end
def obscure_some_key_method
# ...
# ...
end
end
Friday, August 9, 13
“WHO REQUIRED ME?”
p “Required By” => caller[0]
module SomePossiblyIncludedMonkeyPatch
def change_important_class_behavior
# ...
# ...
end
def obscure_some_key_method
# ...
# ...
end
end
Friday, August 9, 13
WHAT IF YOU DON’T
KNOW THE RIGHT
QUESTION YET?
Friday, August 9, 13
USE DEBUGGER!
Friday, August 9, 13
YOUR GEMFILE
source 'http://rubygems.org'
gem 'rails', '3.2.12'
gem 'rack', '~> 1.4.0'
gem 'rake'
gem "will_paginate"
gem 'devise'
group :development, :test do
gem 'rspec'
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'debugger'
end
Friday, August 9, 13
IN THE CODE
class Hash
# Return a new hash with all keys converted to symbols, as
# long as they respond to +to_sym+.
#
# { 'name' => 'Rob', 'years' => '28' }.symbolize_keys
# #=> { :name => "Rob", :years => "28" }
def symbolize_keys
debugger
dup.symbolize_keys!
end
alias_method :to_options, :symbolize_keys
alias_method :to_options!, :symbolize_keys!
# Validate all keys in a hash match *valid keys, raising
ArgumentError on a mismatch.
# Note that keys are NOT treated indifferently, meaning if you
use strings for keys but assert symbols
Friday, August 9, 13
RUNNING IT
Friday, August 9, 13
RUNNING IT
$ rails server -u
Development Server:
Friday, August 9, 13
RUNNING IT
$ rails server -u
Development Server:
$ rspec -d spec/
rSpec:
Friday, August 9, 13
RUNNING IT
Arbitrary Ruby script:
$ rdebug <command>
$ rdebug rake db:seed
Friday, August 9, 13
WHO ARE YOU?
#activesupport-3.2.12/lib/active_support/core_ext/hash
class Hash
def symbolize_keys
debugger
dup.symbolize_keys!
end
Friday, August 9, 13
WHO ARE YOU?
(rdb:1) eval dup.class
#activesupport-3.2.12/lib/active_support/core_ext/hash
class Hash
def symbolize_keys
debugger
dup.symbolize_keys!
end
Friday, August 9, 13
WHO ARE YOU?
(rdb:1) eval dup.class
Hash
#activesupport-3.2.12/lib/active_support/core_ext/hash
class Hash
def symbolize_keys
debugger
dup.symbolize_keys!
end
Friday, August 9, 13
WHO AM I?
(rdb:1) eval self.class
Friday, August 9, 13
WHO AM I?
(rdb:1) eval self.class
Hash
Friday, August 9, 13
WHO CAN I CALL?
(rdb:1) eval self.methods
Friday, August 9, 13
WHO CAN I CALL?
(rdb:1) eval self.methods
[:specify, :class_variable_defined?, :public_class_method,
:methods, :use_instantiated_fixtures=, :filtered_examples,
:before_all_ivars, :should, :const_defined?, :untrust,
:local_constant_names, :should_not, :capture, :module_eval,
:instance_methods, :clone, :load_dependency, :to_json, :run_hook,
:all_apply?, :share_examples_for, :include?, :redefine_method,
:to_yaml, :respond_to?, :examples, :fail_fast?, :unloadable,
:it_should_behave_like, :<=>, :instance_variable_defined?,
:register, :acts_like?, :psych_yaml_as, :debug_method,
:fixture_class_names, :let!, :render_views, :focus,
:private_class_method, :delegate, :public_constant,
:singleton_methods, :pretty_print_instance_variables,
:attr_internal_writer, :use_instantiated_fixtures?, :matcher,
:try, :tests, :as_json, :gem, :untrusted?, :controller_class,
:pending, :parent, :silence, :class_eval,
Friday, August 9, 13
WHO CAN I CALL?
(rdb:1) eval self.methods.sort
Friday, August 9, 13
WHO CAN I CALL?
(rdb:1) eval self.methods.sort
[:!, :!=, :!~, :<=>, :==, :===, :=~, :[], :
[]=, :__id__, :__send__, :`, :acts_like?, :all?, :any?, :as_json,
:assert_valid_keys, :assoc, :binding_n, :blank?, :breakpoint,
:capture, :chunk, :class, :class_eval, :clear, :clone, :collect,
:collect_concat, :compare_by_identity, :compare_by_identity?,
:count, :cycle, :dbg_print, :dbg_puts, :debugger, :deep_dup,
:deep_merge, :deep_merge!, :deep_symbolize_keys, :default,
:default=, :default_proc, :default_proc=,
:define_singleton_method, :delete, :delete_if, :detect, :diff,
:display, :drop, :drop_while, :dup, :duplicable?, :each,
:each_cons, :each_entry, :each_key, :each_pair, :each_slice,
:each_value, :each_with_index, :each_with_object, :empty?,
:enable_warnings, :encode_json, :entries, :enum_for, :eql?,
:equal?, :except, :except!, :exclude?, :extend, :extract!,
:extractable_options?, :fetch, :find, :find_all, :find_index,
Friday, August 9, 13
WHO CAN I CALL?
(rdb:1) eval self.methods.grep(/merge/)
Friday, August 9, 13
WHO CAN I CALL?
(rdb:1) eval self.methods.grep(/merge/)
[:deep_merge!, :reverse_merge!, :merge!, :merge, :deep_merge,
:reverse_merge, :merge_resultset]
Friday, August 9, 13
DEBUGGER HAS ‘PP’
BY DEFAULT
Friday, August 9, 13
WHO DO YOU INCLUDE?
(rdb:1) pp dup.class.included_modules
Friday, August 9, 13
WHO DO YOU INCLUDE?
(rdb:1) pp dup.class.included_modules
[SimpleCov::HashMergeHelper,
JSON::Ext::Generator::GeneratorMethods::Hash,
Enumerable,
RSpec::Steps::ClassMethods,
JSON::Ext::Generator::GeneratorMethods::Object,
ActiveSupport::Dependencies::Loadable,
PP::ObjectMixin,
Kernel]
Friday, August 9, 13
FINDING
METHODS
Friday, August 9, 13
AT THE COMMAND-LINE
-H (show filename)
-n (show line number)
-r (recurse directories)
-i (ignore case -- use carefully)
$ grep -Hnir <pattern> <path>
Friday, August 9, 13
USEFUL PATTERNS
Friday, August 9, 13
USEFUL PATTERNS
$ grep -Hnr “def *my_method” *
Method definitions:
Friday, August 9, 13
USEFUL PATTERNS
$ grep -Hnr “def *my_method” *
Method definitions:
$ grep <stuff> | grep -v “ *#”
Ignore comments:
Friday, August 9, 13
ACK > GREP
$ ack <pattern>
Friday, August 9, 13
ACK > GREP
Friday, August 9, 13
ACK > GREP
•Looks only in programming files (ignores
logs!)
Friday, August 9, 13
ACK > GREP
•Looks only in programming files (ignores
logs!)
•brew install ack
Friday, August 9, 13
ACK > GREP
•Looks only in programming files (ignores
logs!)
•brew install ack
•Configurable via .ackrc
Friday, August 9, 13
ACK > GREP
•Looks only in programming files (ignores
logs!)
•brew install ack
•Configurable via .ackrc
•https://gist.github.com/IdahoEv/5580770
Friday, August 9, 13
BUT THEN THIS...
Friday, August 9, 13
BUT THEN THIS...
$ ack “def *my_method”
Friday, August 9, 13
BUT THEN THIS...
$ ack “def *my_method”
$
Friday, August 9, 13
BUT THEN THIS...
$ ack “def *my_method”
$
... it doesn’t exist
Friday, August 9, 13
BUT THEN THIS...
$ ack “def *my_method”
$
... it doesn’t exist
Friday, August 9, 13
BECAUSE RUBY LETS
YOU DO THIS...
Friday, August 9, 13
module RSpec
module Core
class ExampleGroup
class << self
delegate_to_metadata :described_class, :file_path
alias_method :display_name, :description
alias_method :describes, :described_class
# @private
# @macro [attach] define_example_method
# @param [String] name
# @param [Hash] extra_options
# @param [Block] implementation
def self.define_example_method(name, extra_options={})
module_eval(<<-END_RUBY, __FILE__, __LINE__)
def #{name}(desc=nil, *args, &block)
options = build_metadata_hash_from(args)
options.update(:pending => RSpec::Core::Pending::) unless block
options.update(#{extra_options.inspect})
examples << RSpec::Core::Example.new(self, desc, options, block)
examples.last
end
END_RUBY
end
define_example_method :example
define_example_method :it
define_example_method :specify
define_example_method :focus, :focused => true, :focus => true
Friday, August 9, 13
module RSpec
module Core
class ExampleGroup
class << self
delegate_to_metadata :described_class, :file_path
alias_method :display_name, :description
alias_method :describes, :described_class
# @private
# @macro [attach] define_example_method
# @param [String] name
# @param [Hash] extra_options
# @param [Block] implementation
def self.define_example_method(name, extra_options={})
module_eval(<<-END_RUBY, __FILE__, __LINE__)
def #{name}(desc=nil, *args, &block)
options = build_metadata_hash_from(args)
options.update(:pending => RSpec::Core::Pending::) unless block
options.update(#{extra_options.inspect})
examples << RSpec::Core::Example.new(self, desc, options, block)
examples.last
end
END_RUBY
end
define_example_method :example
define_example_method :it
define_example_method :specify
define_example_method :focus, :focused => true, :focus => true
Friday, August 9, 13
ADVANCED
INTROSPECTION
Friday, August 9, 13
WHO DO YOU INCLUDE?
#activesupport-3.2.12/lib/active_support/core_ext/hash
class Hash
# ... snip ...
def symbolize_keys
debugger
dup.symbolize_keys!
end
# ... snip ...
end
Friday, August 9, 13
WHO DO YOU INCLUDE?
(rdb:1) pp self.class.included_modules
[SimpleCov::HashMergeHelper,
JSON::Ext::Generator::GeneratorMethods::Hash,
Enumerable,
RSpec::Steps::ClassMethods,
JSON::Ext::Generator::GeneratorMethods::Object,
ActiveSupport::Dependencies::Loadable,
PP::ObjectMixin,
Kernel]
Friday, August 9, 13
WHO DEFINED THAT METHOD?
(rdb:1) eval self.method(:merge_resultset).owner
Friday, August 9, 13
WHO DEFINED THAT METHOD?
(rdb:1) eval self.method(:merge_resultset).owner
SimpleCov::HashMergeHelper
Friday, August 9, 13
BUT DEFINED WHERE?
(rdb:1) pp self.method(:merge_resultset).source_location
Friday, August 9, 13
BUT DEFINED WHERE?
(rdb:1) pp self.method(:merge_resultset).source_location
["~/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/
simplecov-0.5.4/lib/simplecov/merge_helpers.rb", 25]
Friday, August 9, 13
EVEN WORKS ON
DYNAMIC METHODS!
Friday, August 9, 13
EVEN WORKS ON
DYNAMIC METHODS!
#/spec/controllers/invoices_controller_spec.rb
require 'spec_helper'
describe InvoicesController do
debugger
describe "as an admin" do
before(:each) do
authenticate(:admin)
Friday, August 9, 13
EVEN WORKS ON
DYNAMIC METHODS!
(rdb:1) eval method(:example).source_location
Friday, August 9, 13
EVEN WORKS ON
DYNAMIC METHODS!
(rdb:1) eval method(:example).source_location
["/Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-
fast@tracks/gems/rspec-core-2.13.1/lib/rspec/core/
example_group.rb", 61]
Friday, August 9, 13
WHERE TO LOOK NEXT
•Pry (https://github.com/pry/pry)
•API Docs: http://www.ruby-doc.org/core-2.0
• Kernel
• Module
• Method
Friday, August 9, 13
Thanks!
Evan Dorn
Founder, Logical Reality Design
http://lrdesign.com
evan@lrdesign.com
@idahoev
Text
Friday, August 9, 13
Ad

More Related Content

What's hot (20)

Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
Ben Mabey
 
Magento - a Zend Framework Application
Magento - a Zend Framework ApplicationMagento - a Zend Framework Application
Magento - a Zend Framework Application
ZendCon
 
Ajax Applications with RichFaces and JSF 2
Ajax Applications with RichFaces and JSF 2Ajax Applications with RichFaces and JSF 2
Ajax Applications with RichFaces and JSF 2
Max Katz
 
Application Diagnosis with Zend Server Tracing
Application Diagnosis with Zend Server TracingApplication Diagnosis with Zend Server Tracing
Application Diagnosis with Zend Server Tracing
ZendCon
 
Progressive Enhancement
Progressive EnhancementProgressive Enhancement
Progressive Enhancement
Zach Leatherman
 
สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1
ทวิร พานิชสมบัติ
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With Cucumber
Sean Cribbs
 
End-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystemEnd-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystem
Alex Mikitenko
 
A Debugging Adventure: Journey through Ember.js Glue
A Debugging Adventure: Journey through Ember.js GlueA Debugging Adventure: Journey through Ember.js Glue
A Debugging Adventure: Journey through Ember.js Glue
Mike North
 
EPiServer Web Parts
EPiServer Web PartsEPiServer Web Parts
EPiServer Web Parts
EPiServer Meetup Oslo
 
"Managing API Complexity". Matthew Flaming, Temboo
"Managing API Complexity". Matthew Flaming, Temboo"Managing API Complexity". Matthew Flaming, Temboo
"Managing API Complexity". Matthew Flaming, Temboo
Yandex
 
Intro to Rails
Intro to RailsIntro to Rails
Intro to Rails
lvrubygroup
 
Outside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and RspecOutside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and Rspec
Joseph Wilk
 
How do speed up web pages? CSS & HTML Tricks
How do speed up web pages? CSS & HTML TricksHow do speed up web pages? CSS & HTML Tricks
How do speed up web pages? CSS & HTML Tricks
Compare Infobase Limited
 
Optaros Surf Code Camp Walkthrough 2
Optaros Surf Code Camp Walkthrough 2Optaros Surf Code Camp Walkthrough 2
Optaros Surf Code Camp Walkthrough 2
Jeff Potts
 
Streamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web FrameworksStreamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web Frameworks
guestf7bc30
 
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpOptimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Matthew Davis
 
Palestra VCR
Palestra VCRPalestra VCR
Palestra VCR
Cássio Marques
 
Master the New Core of Drupal 8 Now: with Symfony and Silex
Master the New Core of Drupal 8 Now: with Symfony and SilexMaster the New Core of Drupal 8 Now: with Symfony and Silex
Master the New Core of Drupal 8 Now: with Symfony and Silex
Ryan Weaver
 
Enemy of the state
Enemy of the stateEnemy of the state
Enemy of the state
Mike North
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
Ben Mabey
 
Magento - a Zend Framework Application
Magento - a Zend Framework ApplicationMagento - a Zend Framework Application
Magento - a Zend Framework Application
ZendCon
 
Ajax Applications with RichFaces and JSF 2
Ajax Applications with RichFaces and JSF 2Ajax Applications with RichFaces and JSF 2
Ajax Applications with RichFaces and JSF 2
Max Katz
 
Application Diagnosis with Zend Server Tracing
Application Diagnosis with Zend Server TracingApplication Diagnosis with Zend Server Tracing
Application Diagnosis with Zend Server Tracing
ZendCon
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With Cucumber
Sean Cribbs
 
End-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystemEnd-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystem
Alex Mikitenko
 
A Debugging Adventure: Journey through Ember.js Glue
A Debugging Adventure: Journey through Ember.js GlueA Debugging Adventure: Journey through Ember.js Glue
A Debugging Adventure: Journey through Ember.js Glue
Mike North
 
"Managing API Complexity". Matthew Flaming, Temboo
"Managing API Complexity". Matthew Flaming, Temboo"Managing API Complexity". Matthew Flaming, Temboo
"Managing API Complexity". Matthew Flaming, Temboo
Yandex
 
Outside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and RspecOutside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and Rspec
Joseph Wilk
 
How do speed up web pages? CSS & HTML Tricks
How do speed up web pages? CSS & HTML TricksHow do speed up web pages? CSS & HTML Tricks
How do speed up web pages? CSS & HTML Tricks
Compare Infobase Limited
 
Optaros Surf Code Camp Walkthrough 2
Optaros Surf Code Camp Walkthrough 2Optaros Surf Code Camp Walkthrough 2
Optaros Surf Code Camp Walkthrough 2
Jeff Potts
 
Streamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web FrameworksStreamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web Frameworks
guestf7bc30
 
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpOptimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Matthew Davis
 
Master the New Core of Drupal 8 Now: with Symfony and Silex
Master the New Core of Drupal 8 Now: with Symfony and SilexMaster the New Core of Drupal 8 Now: with Symfony and Silex
Master the New Core of Drupal 8 Now: with Symfony and Silex
Ryan Weaver
 
Enemy of the state
Enemy of the stateEnemy of the state
Enemy of the state
Mike North
 

Viewers also liked (6)

Gal presentation
Gal presentationGal presentation
Gal presentation
Anna Schmitt
 
Doag2011 unternehmensanwendungen adf_mobile_next_vl_jm_final
Doag2011 unternehmensanwendungen adf_mobile_next_vl_jm_finalDoag2011 unternehmensanwendungen adf_mobile_next_vl_jm_final
Doag2011 unternehmensanwendungen adf_mobile_next_vl_jm_final
Volker Linz
 
Knockout mvvm-m6-slides
Knockout mvvm-m6-slidesKnockout mvvm-m6-slides
Knockout mvvm-m6-slides
MasterCode.vn
 
NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05
lrdesign
 
Modern Web Development
Modern Web DevelopmentModern Web Development
Modern Web Development
Robert Nyman
 
Presentacion de la práctica de Ajax 2016
Presentacion de la práctica de Ajax 2016Presentacion de la práctica de Ajax 2016
Presentacion de la práctica de Ajax 2016
Carlos Almarcha Ruiz
 
Doag2011 unternehmensanwendungen adf_mobile_next_vl_jm_final
Doag2011 unternehmensanwendungen adf_mobile_next_vl_jm_finalDoag2011 unternehmensanwendungen adf_mobile_next_vl_jm_final
Doag2011 unternehmensanwendungen adf_mobile_next_vl_jm_final
Volker Linz
 
Knockout mvvm-m6-slides
Knockout mvvm-m6-slidesKnockout mvvm-m6-slides
Knockout mvvm-m6-slides
MasterCode.vn
 
NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05
lrdesign
 
Modern Web Development
Modern Web DevelopmentModern Web Development
Modern Web Development
Robert Nyman
 
Presentacion de la práctica de Ajax 2016
Presentacion de la práctica de Ajax 2016Presentacion de la práctica de Ajax 2016
Presentacion de la práctica de Ajax 2016
Carlos Almarcha Ruiz
 
Ad

Similar to Code diving in Ruby and Rails (20)

Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817
Tse-Ching Ho
 
To Batch Or Not To Batch
To Batch Or Not To BatchTo Batch Or Not To Batch
To Batch Or Not To Batch
Luca Mearelli
 
Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!
cloudbring
 
Intro to-rails-webperf
Intro to-rails-webperfIntro to-rails-webperf
Intro to-rails-webperf
New Relic
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
Marcelo Pinheiro
 
10 tips for Redux at scale
10 tips for Redux at scale10 tips for Redux at scale
10 tips for Redux at scale
inovia
 
Redux at scale
Redux at scaleRedux at scale
Redux at scale
inovia
 
Ruby For Startups
Ruby For StartupsRuby For Startups
Ruby For Startups
Mike Subelsky
 
Picking gem ruby for penetration testers
Picking gem ruby for penetration testersPicking gem ruby for penetration testers
Picking gem ruby for penetration testers
Paolo Perego
 
Advanced App Building - Tips, Tricks & Lessons Learned
Advanced App Building - Tips, Tricks & Lessons LearnedAdvanced App Building - Tips, Tricks & Lessons Learned
Advanced App Building - Tips, Tricks & Lessons Learned
Jay Graves
 
20141210 rakuten techtalk
20141210 rakuten techtalk20141210 rakuten techtalk
20141210 rakuten techtalk
Hiroshi SHIBATA
 
Introduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman OrtegaIntroduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman Ortega
arman o
 
Gem That (2009)
Gem That (2009)Gem That (2009)
Gem That (2009)
lazyatom
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
Alan Pinstein
 
CICONF 2012 - Don't Make Me Read Your Mind
CICONF 2012 - Don't Make Me Read Your MindCICONF 2012 - Don't Make Me Read Your Mind
CICONF 2012 - Don't Make Me Read Your Mind
ciconf
 
Building Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in RailsBuilding Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in Rails
Jim Jeffers
 
Using Ruby in Android Development
Using Ruby in Android DevelopmentUsing Ruby in Android Development
Using Ruby in Android Development
Adam Blum
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro framework
Jeremy Kendall
 
The Future of Dependency Management for Ruby
The Future of Dependency Management for RubyThe Future of Dependency Management for Ruby
The Future of Dependency Management for Ruby
Hiroshi SHIBATA
 
Blow up when things are wrong
Blow up when things are wrongBlow up when things are wrong
Blow up when things are wrong
Vesa Vänskä
 
Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817
Tse-Ching Ho
 
To Batch Or Not To Batch
To Batch Or Not To BatchTo Batch Or Not To Batch
To Batch Or Not To Batch
Luca Mearelli
 
Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!
cloudbring
 
Intro to-rails-webperf
Intro to-rails-webperfIntro to-rails-webperf
Intro to-rails-webperf
New Relic
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
Marcelo Pinheiro
 
10 tips for Redux at scale
10 tips for Redux at scale10 tips for Redux at scale
10 tips for Redux at scale
inovia
 
Redux at scale
Redux at scaleRedux at scale
Redux at scale
inovia
 
Picking gem ruby for penetration testers
Picking gem ruby for penetration testersPicking gem ruby for penetration testers
Picking gem ruby for penetration testers
Paolo Perego
 
Advanced App Building - Tips, Tricks & Lessons Learned
Advanced App Building - Tips, Tricks & Lessons LearnedAdvanced App Building - Tips, Tricks & Lessons Learned
Advanced App Building - Tips, Tricks & Lessons Learned
Jay Graves
 
20141210 rakuten techtalk
20141210 rakuten techtalk20141210 rakuten techtalk
20141210 rakuten techtalk
Hiroshi SHIBATA
 
Introduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman OrtegaIntroduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman Ortega
arman o
 
Gem That (2009)
Gem That (2009)Gem That (2009)
Gem That (2009)
lazyatom
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
Alan Pinstein
 
CICONF 2012 - Don't Make Me Read Your Mind
CICONF 2012 - Don't Make Me Read Your MindCICONF 2012 - Don't Make Me Read Your Mind
CICONF 2012 - Don't Make Me Read Your Mind
ciconf
 
Building Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in RailsBuilding Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in Rails
Jim Jeffers
 
Using Ruby in Android Development
Using Ruby in Android DevelopmentUsing Ruby in Android Development
Using Ruby in Android Development
Adam Blum
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro framework
Jeremy Kendall
 
The Future of Dependency Management for Ruby
The Future of Dependency Management for RubyThe Future of Dependency Management for Ruby
The Future of Dependency Management for Ruby
Hiroshi SHIBATA
 
Blow up when things are wrong
Blow up when things are wrongBlow up when things are wrong
Blow up when things are wrong
Vesa Vänskä
 
Ad

Recently uploaded (20)

TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 

Code diving in Ruby and Rails

  • 1. Code Diving in Ruby Evan Dorn Founder, Logical Reality Design http://lrdesign.com [email protected] @idahoev Friday, August 9, 13
  • 2. SO YOU’RE CODING ALONG WHEN... Friday, August 9, 13
  • 3. 1) InvoicesController as an admin GET index should paginate all unpaid invoices as @unpaid_invoices Failure/Error: get :index NoMethodError: undefined method `unpayed' for #<Class:0x007fd8cfe9ee18> # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activerecord-3.2.12/lib/active_record/dynamic_matchers.rb:55:in `method_missing' # ./app/controllers/invoices_controller.rb:7:in `index' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/action_controller/metal/implicit_render.rb:4:in `send_action' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/abstract_controller/base.rb:167:in `process_action' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/action_controller/metal/rendering.rb:10:in `process_action' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/abstract_controller/callbacks.rb:18:in `block in process_action' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activesupport-3.2.12/lib/active_support/callbacks.rb:447:in `_run__3859364058582123788__process_action__4176185741589430016__callbacks' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/abstract_controller/callbacks.rb:17:in `process_action' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/action_controller/metal/rescue.rb:29:in `process_action' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action' Friday, August 9, 13
  • 5. BUT THEN YOU NOTICE THIS... Friday, August 9, 13
  • 6. 1) InvoicesController as an admin GET index should paginate all unpaid invoices as @unpaid_invoices Failure/Error: get :index NoMethodError: undefined method `unpayed' for #<Class:0x007fd8cfe9ee18> # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activerecord-3.2.12/lib/active_record/dynamic_matchers.rb:55:in `method_missing' # ./app/controllers/invoices_controller.rb:7:in `index' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/action_controller/metal/implicit_render.rb:4:in `send_action' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/abstract_controller/base.rb:167:in `process_action' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/action_controller/metal/rendering.rb:10:in `process_action' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/abstract_controller/callbacks.rb:18:in `block in process_action' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activesupport-3.2.12/lib/active_support/callbacks.rb:447:in `_run__3859364058582123788__process_action__4176185741589430016__callbacks' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/abstract_controller/callbacks.rb:17:in `process_action' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/action_controller/metal/rescue.rb:29:in `process_action' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action' Friday, August 9, 13
  • 7. 1) InvoicesController as an admin GET index should paginate all unpaid invoices as @unpaid_invoices Failure/Error: get :index NoMethodError: undefined method `unpayed' for #<Class:0x007fd8cfe9ee18> # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activerecord-3.2.12/lib/active_record/dynamic_matchers.rb:55:in `method_missing' # ./app/controllers/invoices_controller.rb:7:in `index' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/action_controller/metal/implicit_render.rb:4:in `send_action' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/abstract_controller/base.rb:167:in `process_action' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/action_controller/metal/rendering.rb:10:in `process_action' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/abstract_controller/callbacks.rb:18:in `block in process_action' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activesupport-3.2.12/lib/active_support/callbacks.rb:447:in `_run__3859364058582123788__process_action__4176185741589430016__callbacks' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/abstract_controller/callbacks.rb:17:in `process_action' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/action_controller/metal/rescue.rb:29:in `process_action' # /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action' Friday, August 9, 13
  • 9. /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/active_support/ core_ext/hash/keys.rb:25:in `symbolize_keys': You blew it, dumbass (RuntimeError) from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/connection_adapters/abstract/connection_specification.rb:45:in `resolve_hash_connection' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:36:in `instance_eval' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:36:in `execute_hook' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:26:in `block in on_load' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:25:in `each' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:25:in `on_load' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/railtie.rb:74:in `block in <class:Railtie>' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:30:in `instance_exec' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:30:in `run' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:55:in `block in run_initializers' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:54:in `each' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:54:in `run_initializers' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ application.rb:136:in `initialize!' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ railtie/configurable.rb:30:in `method_missing' from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/config/environment.rb:5:in `<top (required)>' from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/spec/spec_helper.rb:3:in `require' from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/spec/spec_helper.rb:3:in `<top Friday, August 9, 13
  • 10. /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/active_support/ core_ext/hash/keys.rb:25:in `symbolize_keys': You blew it, dumbass (RuntimeError) from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/connection_adapters/abstract/connection_specification.rb:45:in `resolve_hash_connection' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:36:in `instance_eval' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:36:in `execute_hook' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:26:in `block in on_load' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:25:in `each' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:25:in `on_load' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/railtie.rb:74:in `block in <class:Railtie>' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:30:in `instance_exec' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:30:in `run' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:55:in `block in run_initializers' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:54:in `each' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:54:in `run_initializers' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ application.rb:136:in `initialize!' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ railtie/configurable.rb:30:in `method_missing' from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/config/environment.rb:5:in `<top (required)>' from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/spec/spec_helper.rb:3:in `require' from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/spec/spec_helper.rb:3:in `<top Friday, August 9, 13
  • 11. /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/active_support/ core_ext/hash/keys.rb:25:in `symbolize_keys': You blew it, dumbass (RuntimeError) from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/connection_adapters/abstract/connection_specification.rb:45:in `resolve_hash_connection' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:36:in `instance_eval' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:36:in `execute_hook' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:26:in `block in on_load' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:25:in `each' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:25:in `on_load' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/railtie.rb:74:in `block in <class:Railtie>' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:30:in `instance_exec' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:30:in `run' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:55:in `block in run_initializers' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:54:in `each' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:54:in `run_initializers' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ application.rb:136:in `initialize!' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ railtie/configurable.rb:30:in `method_missing' from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/config/environment.rb:5:in `<top (required)>' from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/spec/spec_helper.rb:3:in `require' from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/spec/spec_helper.rb:3:in `<top Friday, August 9, 13
  • 12. /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/active_support/ core_ext/hash/keys.rb:25:in `symbolize_keys': You blew it, dumbass (RuntimeError) from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/connection_adapters/abstract/connection_specification.rb:45:in `resolve_hash_connection' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:36:in `instance_eval' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:36:in `execute_hook' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:26:in `block in on_load' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:25:in `each' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/ active_support/lazy_load_hooks.rb:25:in `on_load' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activerecord-3.2.12/lib/ active_record/railtie.rb:74:in `block in <class:Railtie>' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:30:in `instance_exec' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:30:in `run' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:55:in `block in run_initializers' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:54:in `each' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ initializable.rb:54:in `run_initializers' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ application.rb:136:in `initialize!' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/railties-3.2.12/lib/rails/ railtie/configurable.rb:30:in `method_missing' from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/config/environment.rb:5:in `<top (required)>' from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/spec/spec_helper.rb:3:in `require' from /Volumes/Valinor/Users/evan/Development/Ruby/apps/tracks/spec/spec_helper.rb:3:in `<top Friday, August 9, 13
  • 13. IT’S PROBABLY SOMETHING YOU DID. Friday, August 9, 13
  • 14. IT’S PROBABLY SOMETHING YOU DID. (but the error’s not in your code) Friday, August 9, 13
  • 15. RAILS’ CODE IS HARD TO UNDERSTAND Friday, August 9, 13
  • 16. RAILS’ CODE IS HARD TO UNDERSTAND But that doesn’t matter! Dive in anyway. Friday, August 9, 13
  • 17. RUBY IS A RUN-TIME LANGUAGE Friday, August 9, 13
  • 18. RUBY IS A RUN-TIME LANGUAGE •This makes it hard to find stuff! Friday, August 9, 13
  • 19. RUBY IS A RUN-TIME LANGUAGE •This makes it hard to find stuff! •Your IDE isn’t much help Friday, August 9, 13
  • 20. RUBY IS A RUN-TIME LANGUAGE •This makes it hard to find stuff! •Your IDE isn’t much help •So find stuff AT RUN TIME Friday, August 9, 13
  • 21. JUST OPEN THAT FILE Friday, August 9, 13
  • 22. JUST OPEN THAT FILE Don’t be intimidated ... it’s all just Ruby Friday, August 9, 13
  • 23. JUST OPEN THAT FILE ~/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/active_support/ core_ext/hash/keys.rb:25:in `symbolize_keys': You blew it, dumbass (RuntimeError) from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activerecord-3.2.12/lib/active_record/connection_adapters/abstract/ connection_specification.rb:45:in `resolve_hash_connection' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activerecord-3.2.12/lib/active_record/connection_adapters/abstract/ connection_specification.rb:41:in `resolve_string_connection' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ Don’t be intimidated ... it’s all just Ruby Friday, August 9, 13
  • 24. JUST OPEN THAT FILE ~/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12/lib/active_support/ core_ext/hash/keys.rb:25:in `symbolize_keys': You blew it, dumbass (RuntimeError) from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activerecord-3.2.12/lib/active_record/connection_adapters/abstract/ connection_specification.rb:45:in `resolve_hash_connection' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ activerecord-3.2.12/lib/active_record/connection_adapters/abstract/ connection_specification.rb:41:in `resolve_string_connection' from /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ $ vim ~evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/activesupport-3.2.12 Don’t be intimidated ... it’s all just Ruby Friday, August 9, 13
  • 26. USE GEM... $ gem env Friday, August 9, 13
  • 27. USE GEM... RubyGems Environment: - RUBYGEMS VERSION: 1.8.25 - RUBY VERSION: 1.9.3 (2012-11-10 patchlevel 327) [x86_64-darwin11.4.2] - INSTALLATION DIRECTORY: /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fas - RUBY EXECUTABLE: /Volumes/Valinor/Users/evan/.rvm/rubies/ruby-1.9.3-p327-fast/bin/ - EXECUTABLE DIRECTORY: /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327- fast@tracks/bin - RUBYGEMS PLATFORMS: - ruby - x86_64-darwin-11 - GEM PATHS: - /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks - /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@global - GEM CONFIGURATION: $ gem env Friday, August 9, 13
  • 28. USE GEM... RubyGems Environment: - RUBYGEMS VERSION: 1.8.25 - RUBY VERSION: 1.9.3 (2012-11-10 patchlevel 327) [x86_64-darwin11.4.2] - INSTALLATION DIRECTORY: /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fas - RUBY EXECUTABLE: /Volumes/Valinor/Users/evan/.rvm/rubies/ruby-1.9.3-p327-fast/bin/ - EXECUTABLE DIRECTORY: /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327- fast@tracks/bin - RUBYGEMS PLATFORMS: - ruby - x86_64-darwin-11 - GEM PATHS: - /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks - /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@global - GEM CONFIGURATION: $ gem env Friday, August 9, 13
  • 29. USE GEM... RubyGems Environment: - RUBYGEMS VERSION: 1.8.25 - RUBY VERSION: 1.9.3 (2012-11-10 patchlevel 327) [x86_64-darwin11.4.2] - INSTALLATION DIRECTORY: /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fas - RUBY EXECUTABLE: /Volumes/Valinor/Users/evan/.rvm/rubies/ruby-1.9.3-p327-fast/bin/ - EXECUTABLE DIRECTORY: /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327- fast@tracks/bin - RUBYGEMS PLATFORMS: - ruby - x86_64-darwin-11 - GEM PATHS: - /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks - /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@global - GEM CONFIGURATION: $ gem env $ cd /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks Friday, August 9, 13
  • 31. WHAT’S THIS VALUE? #activesupport-3.2.12/lib/active_support/core_ext/hash class Hash # Return a new hash with all keys converted to symbols, as # long as they respond to +to_sym+. # # { 'name' => 'Rob', 'years' => '28' }.symbolize_keys # #=> { :name => "Rob", :years => "28" } def symbolize_keys dup.symbolize_keys! end alias_method :to_options, :symbolize_keys alias_method :to_options!, :symbolize_keys! # Validate all keys in a hash match *valid keys, raising ArgumentError on a mismatch. # Note that keys are NOT treated indifferently, meaning if you use strings for keys but assert symbols Friday, August 9, 13
  • 32. WHAT’S THIS VALUE? #activesupport-3.2.12/lib/active_support/core_ext/hash class Hash # Return a new hash with all keys converted to symbols, as # long as they respond to +to_sym+. # # { 'name' => 'Rob', 'years' => '28' }.symbolize_keys # #=> { :name => "Rob", :years => "28" } def symbolize_keys dup.symbolize_keys! end alias_method :to_options, :symbolize_keys alias_method :to_options!, :symbolize_keys! # Validate all keys in a hash match *valid keys, raising ArgumentError on a mismatch. # Note that keys are NOT treated indifferently, meaning if you use strings for keys but assert symbols Friday, August 9, 13
  • 33. WHAT’S THIS VALUE? #activesupport-3.2.12/lib/active_support/core_ext/hash class Hash # Return a new hash with all keys converted to symbols, as # long as they respond to +to_sym+. # # { 'name' => 'Rob', 'years' => '28' }.symbolize_keys # #=> { :name => "Rob", :years => "28" } def symbolize_keys p self dup.symbolize_keys! end alias_method :to_options, :symbolize_keys alias_method :to_options!, :symbolize_keys! # Validate all keys in a hash match *valid keys, raising ArgumentError on a mismatch. # Note that keys are NOT treated indifferently, meaning if you Friday, August 9, 13
  • 34. TOO MUCH OUTPUT! .{:client_id=>"24"} {"controller"=>"invoices", "action"=>"new"} .{:client_id=>"27"} {"controller"=>"invoices", "action"=>"new"} .{:client_id=>"30"} {"controller"=>"invoices", "action"=>"new"} .{:client_id=>"33"} {"controller"=>"invoices", "action"=>"new"} .{:client_id=>"37"} {"controller"=>"invoices", "action"=>"new"} .{:id=>"19"} {"id"=>"19", "controller"=>"invoices", "action"=>"edit"} .{:id=>"20"} {"id"=>"20", "controller"=>"invoices", "action"=>"edit"} {:controller=>"devise/ sessions", :action=>"new", :use_route=>"login", :only_path=>true} . {:invoice=>{:due_on=>"2013-05-14", :client_id=>"42", :notes=>"value for notes"}} Friday, August 9, 13
  • 35. OUTPUT AND STOP #activesupport-3.2.12/lib/active_support/core_ext/hash class Hash # Return a new hash with all keys converted to symbols, as # long as they respond to +to_sym+. # # { 'name' => 'Rob', 'years' => '28' }.symbolize_keys # #=> { :name => "Rob", :years => "28" } def symbolize_keys raise self # stop running! dup.symbolize_keys! end alias_method :to_options, :symbolize_keys alias_method :to_options!, :symbolize_keys! # Validate all keys in a hash match *valid keys, raising ArgumentError on a mismatch. # Note that keys are NOT treated indifferently, meaning if you Friday, August 9, 13
  • 36. ADD A CONDITION #activesupport-3.2.12/lib/active_support/core_ext/hash class Hash # Return a new hash with all keys converted to symbols, as # long as they respond to +to_sym+. # # { 'name' => 'Rob', 'years' => '28' }.symbolize_keys # #=> { :name => "Rob", :years => "28" } def symbolize_keys raise self if <some condition> dup.symbolize_keys! end alias_method :to_options, :symbolize_keys alias_method :to_options!, :symbolize_keys! # Validate all keys in a hash match *valid keys, raising ArgumentError on a mismatch. # Note that keys are NOT treated indifferently, meaning if you Friday, August 9, 13
  • 37. KEEP TRACK OF LOCATION #activesupport-3.2.12/lib/active_support/core_ext/hash class Hash # Return a new hash with all keys converted to symbols, as # long as they respond to +to_sym+. # # { 'name' => 'Rob', 'years' => '28' }.symbolize_keys # #=> { :name => "Rob", :years => "28" } def symbolize_keys p __FILE__, __LINE__ dup.symbolize_keys! end alias_method :to_options, :symbolize_keys alias_method :to_options!, :symbolize_keys! # Validate all keys in a hash match *valid keys, raising ArgumentError on a mismatch. # Note that keys are NOT treated indifferently, meaning if you Friday, August 9, 13
  • 38. LABEL WITH LOCATION #activesupport-3.2.12/lib/active_support/core_ext/hash class Hash # Return a new hash with all keys converted to symbols, as # long as they respond to +to_sym+. # # { 'name' => 'Rob', 'years' => '28' }.symbolize_keys # #=> { :name => "Rob", :years => "28" } def symbolize_keys p “#{__FILE__}:#{__LINE__}” => self dup.symbolize_keys! end alias_method :to_options, :symbolize_keys alias_method :to_options!, :symbolize_keys! # Validate all keys in a hash match *valid keys, raising ArgumentError on a mismatch. # Note that keys are NOT treated indifferently, meaning if you Friday, August 9, 13
  • 39. TAG WITH A NAME #activesupport-3.2.12/lib/active_support/core_ext/hash class Hash # Return a new hash with all keys converted to symbols, as # long as they respond to +to_sym+. # # { 'name' => 'Rob', 'years' => '28' }.symbolize_keys # #=> { :name => "Rob", :years => "28" } def symbolize_keys p :broken_hash => self dup.symbolize_keys! end alias_method :to_options, :symbolize_keys alias_method :to_options!, :symbolize_keys! # Validate all keys in a hash match *valid keys, raising ArgumentError on a mismatch. # Note that keys are NOT treated indifferently, meaning if you Friday, August 9, 13
  • 40. CLEAN IT UP #activesupport-3.2.12/lib/active_support/core_ext/hash class Hash # Return a new hash with all keys converted to symbols, as # long as they respond to +to_sym+. # # { 'name' => 'Rob', 'years' => '28' }.symbolize_keys # #=> { :name => "Rob", :years => "28" } def symbolize_keys require ‘pp’ pp self dup.symbolize_keys! end alias_method :to_options, :symbolize_keys alias_method :to_options!, :symbolize_keys! # Validate all keys in a hash match *valid keys, raising ArgumentError on a mismatch. Friday, August 9, 13
  • 42. HOW DID I GET HERE? Friday, August 9, 13
  • 43. HOW DID I GET HERE? #activesupport-3.2.12/lib/active_support/core_ext/hash class Hash # Return a new hash with all keys converted to symbols, as # long as they respond to +to_sym+. # # { 'name' => 'Rob', 'years' => '28' }.symbolize_keys # #=> { :name => "Rob", :years => "28" } def symbolize_keys require ‘pp’ pp caller[0..10] dup.symbolize_keys! end alias_method :to_options, :symbolize_keys alias_method :to_options!, :symbolize_keys! # Validate all keys in a hash match *valid keys, raising ArgumentError on a mismatch. Friday, August 9, 13
  • 44. “DOES THIS FILE LOAD?” module SomePossiblyIncludedMonkeyPatch def change_important_class_behavior # ... # ... end def obscure_some_key_method # ... # ... end end Friday, August 9, 13
  • 45. “DOES THIS FILE LOAD?” raise “Yes, somebody required me” module SomePossiblyIncludedMonkeyPatch def change_important_class_behavior # ... # ... end def obscure_some_key_method # ... # ... end end Friday, August 9, 13
  • 46. “WHY DIDN’T THIS FILE LOAD?” Friday, August 9, 13
  • 47. “WHY DIDN’T THIS FILE LOAD?” require ‘some_library/some_junk’ module MyNiftyBehavior def stuff Friday, August 9, 13
  • 48. “WHY DIDN’T THIS FILE LOAD?” require ‘some_library/some_junk’ module MyNiftyBehavior def stuff $ rspec spec/ No such file to load -- some_library/some_junk (LoadError) Friday, August 9, 13
  • 49. “WHY DIDN’T THIS FILE LOAD?” require ‘some_library/some_junk’ module MyNiftyBehavior def stuff $ rspec spec/ No such file to load -- some_library/some_junk (LoadError) ... pretty print the search path Friday, August 9, 13
  • 50. “WHY DIDN’T THIS FILE LOAD?” require ‘some_library/some_junk’ module MyNiftyBehavior def stuff $ rspec spec/ No such file to load -- some_library/some_junk (LoadError) ... pretty print the search path require ‘pp’ pp $: require ‘some_library/some_junk’ module MyNiftyBehavior def stuff Friday, August 9, 13
  • 51. “WHO REQUIRED ME?” module SomePossiblyIncludedMonkeyPatch def change_important_class_behavior # ... # ... end def obscure_some_key_method # ... # ... end end Friday, August 9, 13
  • 52. “WHO REQUIRED ME?” p “Required By” => caller[0] module SomePossiblyIncludedMonkeyPatch def change_important_class_behavior # ... # ... end def obscure_some_key_method # ... # ... end end Friday, August 9, 13
  • 53. WHAT IF YOU DON’T KNOW THE RIGHT QUESTION YET? Friday, August 9, 13
  • 55. YOUR GEMFILE source 'http://rubygems.org' gem 'rails', '3.2.12' gem 'rack', '~> 1.4.0' gem 'rake' gem "will_paginate" gem 'devise' group :development, :test do gem 'rspec' gem 'rspec-rails' gem 'factory_girl_rails' gem 'debugger' end Friday, August 9, 13
  • 56. IN THE CODE class Hash # Return a new hash with all keys converted to symbols, as # long as they respond to +to_sym+. # # { 'name' => 'Rob', 'years' => '28' }.symbolize_keys # #=> { :name => "Rob", :years => "28" } def symbolize_keys debugger dup.symbolize_keys! end alias_method :to_options, :symbolize_keys alias_method :to_options!, :symbolize_keys! # Validate all keys in a hash match *valid keys, raising ArgumentError on a mismatch. # Note that keys are NOT treated indifferently, meaning if you use strings for keys but assert symbols Friday, August 9, 13
  • 58. RUNNING IT $ rails server -u Development Server: Friday, August 9, 13
  • 59. RUNNING IT $ rails server -u Development Server: $ rspec -d spec/ rSpec: Friday, August 9, 13
  • 60. RUNNING IT Arbitrary Ruby script: $ rdebug <command> $ rdebug rake db:seed Friday, August 9, 13
  • 61. WHO ARE YOU? #activesupport-3.2.12/lib/active_support/core_ext/hash class Hash def symbolize_keys debugger dup.symbolize_keys! end Friday, August 9, 13
  • 62. WHO ARE YOU? (rdb:1) eval dup.class #activesupport-3.2.12/lib/active_support/core_ext/hash class Hash def symbolize_keys debugger dup.symbolize_keys! end Friday, August 9, 13
  • 63. WHO ARE YOU? (rdb:1) eval dup.class Hash #activesupport-3.2.12/lib/active_support/core_ext/hash class Hash def symbolize_keys debugger dup.symbolize_keys! end Friday, August 9, 13
  • 64. WHO AM I? (rdb:1) eval self.class Friday, August 9, 13
  • 65. WHO AM I? (rdb:1) eval self.class Hash Friday, August 9, 13
  • 66. WHO CAN I CALL? (rdb:1) eval self.methods Friday, August 9, 13
  • 67. WHO CAN I CALL? (rdb:1) eval self.methods [:specify, :class_variable_defined?, :public_class_method, :methods, :use_instantiated_fixtures=, :filtered_examples, :before_all_ivars, :should, :const_defined?, :untrust, :local_constant_names, :should_not, :capture, :module_eval, :instance_methods, :clone, :load_dependency, :to_json, :run_hook, :all_apply?, :share_examples_for, :include?, :redefine_method, :to_yaml, :respond_to?, :examples, :fail_fast?, :unloadable, :it_should_behave_like, :<=>, :instance_variable_defined?, :register, :acts_like?, :psych_yaml_as, :debug_method, :fixture_class_names, :let!, :render_views, :focus, :private_class_method, :delegate, :public_constant, :singleton_methods, :pretty_print_instance_variables, :attr_internal_writer, :use_instantiated_fixtures?, :matcher, :try, :tests, :as_json, :gem, :untrusted?, :controller_class, :pending, :parent, :silence, :class_eval, Friday, August 9, 13
  • 68. WHO CAN I CALL? (rdb:1) eval self.methods.sort Friday, August 9, 13
  • 69. WHO CAN I CALL? (rdb:1) eval self.methods.sort [:!, :!=, :!~, :<=>, :==, :===, :=~, :[], : []=, :__id__, :__send__, :`, :acts_like?, :all?, :any?, :as_json, :assert_valid_keys, :assoc, :binding_n, :blank?, :breakpoint, :capture, :chunk, :class, :class_eval, :clear, :clone, :collect, :collect_concat, :compare_by_identity, :compare_by_identity?, :count, :cycle, :dbg_print, :dbg_puts, :debugger, :deep_dup, :deep_merge, :deep_merge!, :deep_symbolize_keys, :default, :default=, :default_proc, :default_proc=, :define_singleton_method, :delete, :delete_if, :detect, :diff, :display, :drop, :drop_while, :dup, :duplicable?, :each, :each_cons, :each_entry, :each_key, :each_pair, :each_slice, :each_value, :each_with_index, :each_with_object, :empty?, :enable_warnings, :encode_json, :entries, :enum_for, :eql?, :equal?, :except, :except!, :exclude?, :extend, :extract!, :extractable_options?, :fetch, :find, :find_all, :find_index, Friday, August 9, 13
  • 70. WHO CAN I CALL? (rdb:1) eval self.methods.grep(/merge/) Friday, August 9, 13
  • 71. WHO CAN I CALL? (rdb:1) eval self.methods.grep(/merge/) [:deep_merge!, :reverse_merge!, :merge!, :merge, :deep_merge, :reverse_merge, :merge_resultset] Friday, August 9, 13
  • 72. DEBUGGER HAS ‘PP’ BY DEFAULT Friday, August 9, 13
  • 73. WHO DO YOU INCLUDE? (rdb:1) pp dup.class.included_modules Friday, August 9, 13
  • 74. WHO DO YOU INCLUDE? (rdb:1) pp dup.class.included_modules [SimpleCov::HashMergeHelper, JSON::Ext::Generator::GeneratorMethods::Hash, Enumerable, RSpec::Steps::ClassMethods, JSON::Ext::Generator::GeneratorMethods::Object, ActiveSupport::Dependencies::Loadable, PP::ObjectMixin, Kernel] Friday, August 9, 13
  • 76. AT THE COMMAND-LINE -H (show filename) -n (show line number) -r (recurse directories) -i (ignore case -- use carefully) $ grep -Hnir <pattern> <path> Friday, August 9, 13
  • 78. USEFUL PATTERNS $ grep -Hnr “def *my_method” * Method definitions: Friday, August 9, 13
  • 79. USEFUL PATTERNS $ grep -Hnr “def *my_method” * Method definitions: $ grep <stuff> | grep -v “ *#” Ignore comments: Friday, August 9, 13
  • 80. ACK > GREP $ ack <pattern> Friday, August 9, 13
  • 81. ACK > GREP Friday, August 9, 13
  • 82. ACK > GREP •Looks only in programming files (ignores logs!) Friday, August 9, 13
  • 83. ACK > GREP •Looks only in programming files (ignores logs!) •brew install ack Friday, August 9, 13
  • 84. ACK > GREP •Looks only in programming files (ignores logs!) •brew install ack •Configurable via .ackrc Friday, August 9, 13
  • 85. ACK > GREP •Looks only in programming files (ignores logs!) •brew install ack •Configurable via .ackrc •https://gist.github.com/IdahoEv/5580770 Friday, August 9, 13
  • 86. BUT THEN THIS... Friday, August 9, 13
  • 87. BUT THEN THIS... $ ack “def *my_method” Friday, August 9, 13
  • 88. BUT THEN THIS... $ ack “def *my_method” $ Friday, August 9, 13
  • 89. BUT THEN THIS... $ ack “def *my_method” $ ... it doesn’t exist Friday, August 9, 13
  • 90. BUT THEN THIS... $ ack “def *my_method” $ ... it doesn’t exist Friday, August 9, 13
  • 91. BECAUSE RUBY LETS YOU DO THIS... Friday, August 9, 13
  • 92. module RSpec module Core class ExampleGroup class << self delegate_to_metadata :described_class, :file_path alias_method :display_name, :description alias_method :describes, :described_class # @private # @macro [attach] define_example_method # @param [String] name # @param [Hash] extra_options # @param [Block] implementation def self.define_example_method(name, extra_options={}) module_eval(<<-END_RUBY, __FILE__, __LINE__) def #{name}(desc=nil, *args, &block) options = build_metadata_hash_from(args) options.update(:pending => RSpec::Core::Pending::) unless block options.update(#{extra_options.inspect}) examples << RSpec::Core::Example.new(self, desc, options, block) examples.last end END_RUBY end define_example_method :example define_example_method :it define_example_method :specify define_example_method :focus, :focused => true, :focus => true Friday, August 9, 13
  • 93. module RSpec module Core class ExampleGroup class << self delegate_to_metadata :described_class, :file_path alias_method :display_name, :description alias_method :describes, :described_class # @private # @macro [attach] define_example_method # @param [String] name # @param [Hash] extra_options # @param [Block] implementation def self.define_example_method(name, extra_options={}) module_eval(<<-END_RUBY, __FILE__, __LINE__) def #{name}(desc=nil, *args, &block) options = build_metadata_hash_from(args) options.update(:pending => RSpec::Core::Pending::) unless block options.update(#{extra_options.inspect}) examples << RSpec::Core::Example.new(self, desc, options, block) examples.last end END_RUBY end define_example_method :example define_example_method :it define_example_method :specify define_example_method :focus, :focused => true, :focus => true Friday, August 9, 13
  • 95. WHO DO YOU INCLUDE? #activesupport-3.2.12/lib/active_support/core_ext/hash class Hash # ... snip ... def symbolize_keys debugger dup.symbolize_keys! end # ... snip ... end Friday, August 9, 13
  • 96. WHO DO YOU INCLUDE? (rdb:1) pp self.class.included_modules [SimpleCov::HashMergeHelper, JSON::Ext::Generator::GeneratorMethods::Hash, Enumerable, RSpec::Steps::ClassMethods, JSON::Ext::Generator::GeneratorMethods::Object, ActiveSupport::Dependencies::Loadable, PP::ObjectMixin, Kernel] Friday, August 9, 13
  • 97. WHO DEFINED THAT METHOD? (rdb:1) eval self.method(:merge_resultset).owner Friday, August 9, 13
  • 98. WHO DEFINED THAT METHOD? (rdb:1) eval self.method(:merge_resultset).owner SimpleCov::HashMergeHelper Friday, August 9, 13
  • 99. BUT DEFINED WHERE? (rdb:1) pp self.method(:merge_resultset).source_location Friday, August 9, 13
  • 100. BUT DEFINED WHERE? (rdb:1) pp self.method(:merge_resultset).source_location ["~/evan/.rvm/gems/ruby-1.9.3-p327-fast@tracks/gems/ simplecov-0.5.4/lib/simplecov/merge_helpers.rb", 25] Friday, August 9, 13
  • 101. EVEN WORKS ON DYNAMIC METHODS! Friday, August 9, 13
  • 102. EVEN WORKS ON DYNAMIC METHODS! #/spec/controllers/invoices_controller_spec.rb require 'spec_helper' describe InvoicesController do debugger describe "as an admin" do before(:each) do authenticate(:admin) Friday, August 9, 13
  • 103. EVEN WORKS ON DYNAMIC METHODS! (rdb:1) eval method(:example).source_location Friday, August 9, 13
  • 104. EVEN WORKS ON DYNAMIC METHODS! (rdb:1) eval method(:example).source_location ["/Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p327- fast@tracks/gems/rspec-core-2.13.1/lib/rspec/core/ example_group.rb", 61] Friday, August 9, 13
  • 105. WHERE TO LOOK NEXT •Pry (https://github.com/pry/pry) •API Docs: http://www.ruby-doc.org/core-2.0 • Kernel • Module • Method Friday, August 9, 13
  • 106. Thanks! Evan Dorn Founder, Logical Reality Design http://lrdesign.com [email protected] @idahoev Text Friday, August 9, 13