ruby Errors
22 error patterns
Logstash Grok pattern match failure
logstash.*Error.*Grok.*pattern.*match failure
- •Test pattern with Grok Debugger tool
- •Add tag_on_failure and handle non-matching events
Logstash pipeline terminated unexpectedly
logstash.*PipelineTerminatedError.*pipeline.*shutdown
- •Check Logstash logs for underlying error causing shutdown
- •Increase JVM heap for Logstash: -Xms1g -Xmx1g in jvm.options
Method called on nil object
NoMethodError.*undefined method.*for (nil:NilClass|nil)
- •Use safe navigation operator: object&.method
- •Add nil check: if object.present? or unless object.nil?
Undefined method on object
NoMethodError.*undefined method.*for.*:.*
- •Check the object's class with .class — it may not be what you expect
- •Verify the method exists: object.respond_to?(:method_name)
ActiveRecord record not found
ActiveRecord::RecordNotFound.*Couldn't find.*with
- •Use find_by instead of find — it returns nil instead of raising
- •Add rescue ActiveRecord::RecordNotFound for graceful handling
ActiveRecord validation failure on save!
ActiveRecord::RecordInvalid.*Validation failed
- •Use save instead of save! to get false instead of exception
- •Check model.errors.full_messages for specific validation failures
Rails routing error - no matching route
No route matches.*\{.*\}
- •Run rails routes to see all available routes
- •Add the missing route to config/routes.rb
Pending database migrations
Migrations are pending.*run.*db:migrate
- •Run rails db:migrate to apply pending migrations
- •Run rails db:migrate:status to check migration status
Pending migration prevents app start
ActiveRecord::PendingMigrationError
- •Run rails db:migrate
- •If migration is broken, fix the migration file or run rails db:rollback
Gem version conflict in Bundler
Bundler could not find compatible versions for gem
- •Run bundle update <gem_name> to resolve the specific gem
- •Check Gemfile for overly strict version pins
Required file or gem not found
LoadError.*cannot load such file
- •Install the missing gem: gem install <name> or add to Gemfile
- •Check require statement spelling and path
Uninitialized constant reference
NameError.*uninitialized constant
- •Check class/module naming matches file path (Rails autoloading)
- •Add require or require_relative for the file defining the constant
Wrong number of arguments passed to method
ArgumentError.*wrong number of arguments.*given.*expected
- •Check the method signature for required vs optional parameters
- •Use keyword arguments for clarity: def method(name:, age: nil)
Database column does not exist
ActiveRecord::StatementInvalid.*PG::.*column.*does not exist
- •Create a migration to add the column: rails g migration AddColumnToTable
- •Run pending migrations: rails db:migrate
Required parameter missing from request
ActionController::ParameterMissing.*param is missing or.*empty
- •Ensure the form/request sends the required param nested correctly
- •Check strong params: params.require(:model).permit(:field)
Gem version mismatch at runtime
Gem::LoadError.*Specified.*but.*was loaded
- •Run bundle exec before the command to use Bundler's resolved versions
- •Update the conflicting gem: bundle update <gem>
Unique constraint violation in database
ActiveRecord::RecordNotUnique.*duplicate key value violates unique constraint
- •Add uniqueness validation to model: validates :field, uniqueness: true
- •Use find_or_create_by instead of create
Implicit type conversion error
TypeError.*no implicit conversion of.*into String
- •Explicitly convert: .to_s, .to_i, .to_f as needed
- •Use string interpolation which calls to_s automatically: "value: #{var}"
Ruby syntax error
SyntaxError.*unexpected.*expecting
- •Check for missing end keyword matching if/def/do/class
- •Look for unclosed string literals or parentheses
Database does not exist
ActiveRecord::NoDatabaseError
- •Run rails db:create to create the database
- •Check database.yml for correct database name and credentials
Port already in use
Errno::EADDRINUSE.*Address already in use.*bind
- •Kill the process using the port: lsof -i :3000 then kill PID
- •Use a different port: rails s -p 3001
Undefined variable in view template
ActionView::Template::Error.*undefined local variable or method
- •Pass the variable from controller: @variable in action
- •Use local_assigns.key?(:var) for partials with optional locals