From f596e08018698ea5ad44fca5deae4f31ea176039 Mon Sep 17 00:00:00 2001 From: Abhishek Sisodia Date: Sun, 31 Aug 2025 12:16:44 +0530 Subject: [PATCH 1/2] For attachment type `ActiveStorage::Attached::One` return `blob` Calling `attachment.blobs` would fail with error if attachment is of type `ActiveStorage::Attached::One` --- lib/ruby_llm/active_record/chat_methods.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ruby_llm/active_record/chat_methods.rb b/lib/ruby_llm/active_record/chat_methods.rb index fed3c4afb..352a55c36 100644 --- a/lib/ruby_llm/active_record/chat_methods.rb +++ b/lib/ruby_llm/active_record/chat_methods.rb @@ -286,7 +286,9 @@ def prepare_for_active_storage(attachments) case attachment when ActionDispatch::Http::UploadedFile, ActiveStorage::Blob attachment - when ActiveStorage::Attached::One, ActiveStorage::Attached::Many + when ActiveStorage::Attached::One + attachment.blob + when ActiveStorage::Attached::Many attachment.blobs when Hash attachment.values.map { |v| prepare_for_active_storage(v) } From 0e0485d5c61dfa6221b0af13bdc104c0b85c9de6 Mon Sep 17 00:00:00 2001 From: Abhishek Sisodia Date: Sun, 31 Aug 2025 12:25:52 +0530 Subject: [PATCH 2/2] Accept changes in Gemfiles --- gemfiles/rails_7.1.gemfile.lock | 7 ++++++- gemfiles/rails_7.2.gemfile.lock | 7 ++++++- gemfiles/rails_8.0.gemfile.lock | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index 0bafeefee..93965dfc2 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -148,6 +148,7 @@ GEM concurrent-ruby (~> 1.1) webrick (~> 1.7) websocket-driver (~> 0.7) + ffi (1.17.2-x86_64-darwin) ffi (1.17.2-x86_64-linux-gnu) fiber-annotation (0.2.0) fiber-local (1.1.0) @@ -224,6 +225,8 @@ GEM net-smtp (0.5.1) net-protocol nio4r (2.7.4) + nokogiri (1.18.9-x86_64-darwin) + racc (~> 1.4) nokogiri (1.18.9-x86_64-linux-gnu) racc (~> 1.4) os (1.1.4) @@ -355,6 +358,7 @@ GEM simplecov (~> 0.19) simplecov-html (0.13.2) simplecov_json_formatter (0.1.4) + sqlite3 (2.7.3-x86_64-darwin) sqlite3 (2.7.3-x86_64-linux-gnu) stringio (3.1.7) thor (1.4.0) @@ -380,6 +384,7 @@ GEM zeitwerk (2.7.3) PLATFORMS + x86_64-darwin-21 x86_64-linux DEPENDENCIES @@ -416,4 +421,4 @@ DEPENDENCIES webmock (~> 3.18) BUNDLED WITH - 2.6.9 + 2.5.5 diff --git a/gemfiles/rails_7.2.gemfile.lock b/gemfiles/rails_7.2.gemfile.lock index dcddc93fa..9f580ed83 100644 --- a/gemfiles/rails_7.2.gemfile.lock +++ b/gemfiles/rails_7.2.gemfile.lock @@ -142,6 +142,7 @@ GEM concurrent-ruby (~> 1.1) webrick (~> 1.7) websocket-driver (~> 0.7) + ffi (1.17.2-x86_64-darwin) ffi (1.17.2-x86_64-linux-gnu) fiber-annotation (0.2.0) fiber-local (1.1.0) @@ -217,6 +218,8 @@ GEM net-smtp (0.5.1) net-protocol nio4r (2.7.4) + nokogiri (1.18.9-x86_64-darwin) + racc (~> 1.4) nokogiri (1.18.9-x86_64-linux-gnu) racc (~> 1.4) os (1.1.4) @@ -348,6 +351,7 @@ GEM simplecov (~> 0.19) simplecov-html (0.13.2) simplecov_json_formatter (0.1.4) + sqlite3 (2.7.3-x86_64-darwin) sqlite3 (2.7.3-x86_64-linux-gnu) stringio (3.1.7) thor (1.4.0) @@ -374,6 +378,7 @@ GEM zeitwerk (2.7.3) PLATFORMS + x86_64-darwin-21 x86_64-linux DEPENDENCIES @@ -410,4 +415,4 @@ DEPENDENCIES webmock (~> 3.18) BUNDLED WITH - 2.6.9 + 2.5.5 diff --git a/gemfiles/rails_8.0.gemfile.lock b/gemfiles/rails_8.0.gemfile.lock index 719155017..ba20d55c8 100644 --- a/gemfiles/rails_8.0.gemfile.lock +++ b/gemfiles/rails_8.0.gemfile.lock @@ -142,6 +142,7 @@ GEM concurrent-ruby (~> 1.1) webrick (~> 1.7) websocket-driver (~> 0.7) + ffi (1.17.2-x86_64-darwin) ffi (1.17.2-x86_64-linux-gnu) fiber-annotation (0.2.0) fiber-local (1.1.0) @@ -217,6 +218,8 @@ GEM net-smtp (0.5.1) net-protocol nio4r (2.7.4) + nokogiri (1.18.9-x86_64-darwin) + racc (~> 1.4) nokogiri (1.18.9-x86_64-linux-gnu) racc (~> 1.4) os (1.1.4) @@ -348,6 +351,7 @@ GEM simplecov (~> 0.19) simplecov-html (0.13.2) simplecov_json_formatter (0.1.4) + sqlite3 (2.7.3-x86_64-darwin) sqlite3 (2.7.3-x86_64-linux-gnu) stringio (3.1.7) thor (1.4.0) @@ -374,6 +378,7 @@ GEM zeitwerk (2.7.3) PLATFORMS + x86_64-darwin-21 x86_64-linux DEPENDENCIES @@ -410,4 +415,4 @@ DEPENDENCIES webmock (~> 3.18) BUNDLED WITH - 2.6.9 + 2.5.5