Updated acts_as_* helpers to use canonical 'rails-style' foreign keys#151
Merged
crmne merged 2 commits intocrmne:mainfrom May 6, 2025
Merged
Updated acts_as_* helpers to use canonical 'rails-style' foreign keys#151crmne merged 2 commits intocrmne:mainfrom
crmne merged 2 commits intocrmne:mainfrom
Conversation
… when custom class names are used. Closes crmne#150
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #151 +/- ##
==========================================
+ Coverage 93.57% 93.65% +0.07%
==========================================
Files 87 87
Lines 3160 3199 +39
Branches 421 422 +1
==========================================
+ Hits 2957 2996 +39
Misses 203 203 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
crmne
added a commit
that referenced
this pull request
May 6, 2025
…#151) This updates the acts_as_message, acts_as_chat and acts_as_tool class methods to use Rails-style foreign keys whenever custom class names are used as options. For example: ``` class FooMessage < ActiveRecord::Base acts_as_message chat_class: 'FooChat', tool_call_class: 'FooToolCall' end ``` will now set the foreign key on the `belongs_to :chat` association to be `foo_chat_id`, instead of `chat_id`, and will set the foreign key on `belongs_to :parent_tool_call` association to `foo_tool_call_id` instead of just `tool_call_id`. This is consistent with Rails' naming conventions for class names and foreign keys. Changes are backwards-compatible with existing code/behavior, and don't require a major or minor version bump. Updated test cases to ensure that the associations are working, but didn't re-record VCR tests, since I don't have an OpenAPI key. Closes #150 Co-authored-by: Carmine Paolino <carmine@paolino.me>
Contributor
|
Please re-open - this introduces a regression. |
Owner
|
@bborn best to open a new PR |
Contributor
Author
|
Give me a bit and I can put in a PR that replaces the current hack with ActiveSupport::Inflector.foreign_key |
Contributor
sbounmy
added a commit
to sbounmy/ruby_llm
that referenced
this pull request
May 12, 2025
…ith-image * 'main' of github.com:crmne/ruby_llm: (24 commits) Enhance Rails guide with detailed persistence flow explanation and setup instructions Remove work-in-progress warning from models documentation generation Add validation considerations for Message model and update persistence flow documentation Add note about upcoming OpenAI headers support in v1.3.0 Handle OpenAI organization and project IDs (crmne#162) Refactor acts_as_message and acts_as_tool_call methods to improve parameter handling and default values Remove reasoning section from available models documentation and rake task Remove debug logging for pricing in OpenRouter models Updated models page Fixed pricing parsing for OpenRouter Updated models Add warning about work in progress for Parsera integration in available models documentation Major refactoring of ModelInfo and Parsera API support for listing LLM capabilities and pricing. Fix inflector (crmne#159) Use foreign_key instead of to_s for acts_as methods (crmne#157) Fixes #embed fails when using default embedding model Add support for logging to file via configuration (crmne#148) Updated acts_as_* helpers to use canonical 'rails-style' foreign keys (crmne#151) refactor(media): streamline content formatting methods across providers Fixed Calling `chat.to_llm` keeps appending messages to the message array ...
parruda
pushed a commit
to parruda/ruby_llm
that referenced
this pull request
Nov 18, 2025
…crmne#151) This updates the acts_as_message, acts_as_chat and acts_as_tool class methods to use Rails-style foreign keys whenever custom class names are used as options. For example: ``` class FooMessage < ActiveRecord::Base acts_as_message chat_class: 'FooChat', tool_call_class: 'FooToolCall' end ``` will now set the foreign key on the `belongs_to :chat` association to be `foo_chat_id`, instead of `chat_id`, and will set the foreign key on `belongs_to :parent_tool_call` association to `foo_tool_call_id` instead of just `tool_call_id`. This is consistent with Rails' naming conventions for class names and foreign keys. Changes are backwards-compatible with existing code/behavior, and don't require a major or minor version bump. Updated test cases to ensure that the associations are working, but didn't re-record VCR tests, since I don't have an OpenAPI key. Closes crmne#150 Co-authored-by: Carmine Paolino <carmine@paolino.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This updates the acts_as_message, acts_as_chat and acts_as_tool class methods to use Rails-style foreign keys whenever custom class names are used as options. For example:
will now set the foreign key on the
belongs_to :chatassociation to befoo_chat_id, instead ofchat_id, and will set the foreign key onbelongs_to :parent_tool_callassociation tofoo_tool_call_idinstead of justtool_call_id.This is consistent with Rails' naming conventions for class names and foreign keys. Changes are backwards-compatible with existing code/behavior, and don't require a major or minor version bump.
Updated test cases to ensure that the associations are working, but didn't re-record VCR tests, since I don't have an OpenAPI key.
Closes #150