I'm debugging a Rails application that uses gems from my local environment. Is there a way to place a breakpoint in one of the gem's file and have it trigger when I debug my app ?
Asked
Active
Viewed 120 times
0
-
So it seems that the debug process does trigger as I get a REPL on the Debug Console, but none of the IDE bells and whistles like Call Stack / Variables state show up. – htatche Dec 03 '19 at 11:45
2 Answers
3
How can I see the source code of a gem installed on my machine? should help you
If you need to edit the source code of say Devise, you would run:
bundle open devise
This will open the gem in your default text editor, allowing you to put breakpoints wherever needed.
Alternatively to see where it's stored on your machine try:
bundle show devise

Mark
- 6,112
- 4
- 21
- 46
-
I know how to browse my gem and add a breakpoint. My issue is that when it hits the line the debug process doesn't trigger properly. – htatche Dec 03 '19 at 11:44
-
Sorry I wasn't clear enough with my question. I've added a comment underneath. Thanks for helping out anyway ! – htatche Dec 03 '19 at 11:47
-
1No worries, I think the standard REPL is the most you can get from a pry point inside an engine but not 100% sure – Mark Dec 03 '19 at 11:49
0
You can use gem 'pry-rescue'
and gem 'pry-rails'
in your gemfile to debbug your code. Just put in your group development like this:
group :development do
gem 'pry-rails'
gem 'pry-rescue'
end
in your code you can put
binding.pry
and after that just run your application and your request will stop where you put the binding.pry