move duplicate controller code to application_controller.rb; add debug gems for binding.pry