What Ruby Errors Bugstack Fixes
- NoMethodError: undefined method for nil:NilClass — calling methods on nil objects
- ActiveRecord::RecordNotFound — querying for records that don't exist
- ArgumentError: wrong number of arguments — method arity mismatches
- NameError: uninitialized constant — referencing undefined classes or modules
Install the SDK
Add the gem to your Gemfile, then run bundle install:
gem 'bugstack', '~> 1.0'
Then add one initializer, with your API key and the Bugstack endpoint:
# config/initializers/bugstack.rb
require "bugstack/integrations/rails"
Bugstack.init(
api_key: ENV["BUGSTACK_API_KEY"],
endpoint: ENV.fetch("BUGSTACK_ENDPOINT", "https://dashboard.bugstack.ai/api/ingest/sdk")
)
# Inside Rails' own error pages, so bugstack sees the error before they answer it:
Rails.application.config.middleware.insert_after(
ActionDispatch::DebugExceptions,
Bugstack::Integrations::RackMiddleware
)
Sinatra and plain Ruby are in the installation guide.
Example Fix
Bugstack detects a NoMethodError caused by calling a method on nil and writes a small fix:
Before (broken)
def show
@user = User.find_by(id: params[:id])
@email = @user.email
end
# Runtime error when user is nil:
# NoMethodError: undefined method
# 'email' for nil:NilClass
After (fixed by Bugstack)
def show
@user = User.find_by(id: params[:id])
if @user.nil?
head :not_found
return
end
@email = @user.email
end
How a Ruby fix reaches you
Bugstack’s verification sandbox, where fixes for Python, JavaScript and Go are proven before you see them, does not run Ruby yet. A Ruby fix arrives as a pull request with the cause and the change, your CI runs on it, and you review and merge it. Autopilot does not merge Ruby fixes on its own.
What else Bugstack does for this repository
The SDK is one part. Once your repository is connected, Bugstack also scans your Ruby gems for known vulnerabilities and outdated versions, scans for secrets, and acts on failed deploys if you host on Render. It scans and reports, and it can open pull requests for what it finds. Those pull requests are switched on per account. Every change arrives as a pull request, and you set how much happens without you.