Rails 7 replaced byebug with ruby/debug
source link: https://blog.saeloun.com/2021/09/29/rails-7-ruby-debug-replaces-byebug
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Rails 7 replaced byebug with ruby/debug
Sep 29, 2021 , by Akhil G Krishnan 1 minute readAs we know, debuggers are the main tools for programmers to debug the code easily. With the latest changes in Rails 7, byebug is replaced with ruby/debug.
Byebug has been helping Rails programmers debug their applications since 2014.
We can refer to that PR here.
Rails 7 comes with debug
as its default debugger.
debug
is Ruby’s new debugger
and
will be included in Ruby 3.1.
It is planned to be a standard library of Ruby 3.1.
Adding debug
to Rails 7 will align Rails with Ruby.
Here is an example of debugging in both Byebug and Debug.
Debugging using byebug
class TestController < ApplicationController
def index
name = "Sam"
age = 23
byebug
place = "Boston"
end
end
# Result
[1, 8] in /Users/sam/test_app/app/controllers/test_controller.rb
1: class TestController < ApplicationController
2: def index
3: name = "Sam"
4: age = 23
5: byebug
=> 6: place = "Boston"
7: end
8: end
(byebug) name
"Sam"
Debugging using Ruby Debug,
class TestController < ApplicationController
def index
name = "Sam"
age = 23
binding.break
place = "Boston"
end
end
# Result
[1, 8] in ~/test_app/app/controllers/test_controller.rb
1| class TestController < ApplicationController
2| def index
3| name = "Sam"
4| age = 23
=> 5| binding.break
6| place = "Boston"
7| end
9| end
=>#0 TestController#index at ~/test_app/app/controllers/test_controller.rb:5
#1 ActionController::BasicImplicitRender#send_action(method="index", args=[])
(rdbg) name # ruby
"Sam"
(rdbg) continue # command
For more details regarding commands and features of Ruby Debug, please check this out Ruby-Debug.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK