Pry (http://pry.github.com/) может помочь. Существует метод show-source
, который будет делать это при запуске из консоли. Вот пример, который я сделал локально.
rails c
DEBUG: Chewy strategies stack: [2] <- urgent @ /Users/jmlockl2/.rvm/gems/ruby-2.3.1@ask/gems/chewy-0.9.0/lib/chewy/railtie.rb:49
Loading development environment (Rails 3.2.22.5)
2.3.1 :001 > pry
[1] pry(main)> q=Question.last
Question Load (0.2ms) SELECT `questions`.* FROM `questions` ORDER BY `questions`.`id` DESC LIMIT 1
=> ...
[2] pry(main)> q.email
User Load (0.2ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 535441 LIMIT 1
=> "email@gmail.com"
[3] pry(main)> show-source q.email
[3] pry(main)> show-source q.email
From: /Users/...question.rb @ line 564:
Number of lines: 3
Owner: Question
Visibility: public
def email
self.submitter.present? ? self.submitter.email : ''
end
[4] pry(main)>
Надеюсь, это поможет!