Skip to content

Conversation

sisodiaa
Copy link

What this does

Say there is a model user with one attached profile_document, then following method call would fail resulting in NoMethodError.

chat_record.ask("What's in this document?", with: user.profile_document)
# undefined method 'blobs' for an instance of ActiveStorage::Attached::One (NoMethodError)

To fix this error we need to modify switch statement in prepare_for_active_storage method i.e. for ActiveStorage::Attached::One we should return attachment.blob instead of attachment.blobs.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Performance improvement

Scope check

  • I read the Contributing Guide
  • This aligns with RubyLLM's focus on LLM communication
  • This isn't application-specific logic that belongs in user code
  • This benefits most users, not just my specific use case

Quality check

  • I ran overcommit --install and all hooks pass
  • I tested my changes thoroughly
  • I updated documentation if needed
  • I didn't modify auto-generated files manually (models.json, aliases.json)

API changes

  • Breaking change
  • New public methods/classes
  • Changed method signatures
  • No API changes

Calling `attachment.blobs` would fail with error if attachment is
of type `ActiveStorage::Attached::One`
Copy link

codecov bot commented Sep 3, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 84.61%. Comparing base (34e8d75) to head (3b6574d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
lib/ruby_llm/active_record/chat_methods.rb 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #380      +/-   ##
==========================================
- Coverage   84.65%   84.61%   -0.05%     
==========================================
  Files          35       35              
  Lines        1825     1826       +1     
  Branches      492      493       +1     
==========================================
  Hits         1545     1545              
- Misses        280      281       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Owner

@crmne crmne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add one test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants