Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/ruby_llm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
)
loader.ignore("#{__dir__}/tasks")
loader.ignore("#{__dir__}/generators")
loader.ignore("#{__dir__}/ruby_llm/railtie.rb")
loader.setup

# A delightful Ruby interface to modern AI language models.
Expand Down
46 changes: 24 additions & 22 deletions lib/ruby_llm/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
# frozen_string_literal: true

module RubyLLM
# Rails integration for RubyLLM
class Railtie < Rails::Railtie
initializer 'ruby_llm.inflections' do
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym 'RubyLLM'
if defined?(Rails::Railtie)
module RubyLLM
# Rails integration for RubyLLM
class Railtie < Rails::Railtie
initializer 'ruby_llm.inflections' do
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym 'RubyLLM'
end
end
end

initializer 'ruby_llm.active_record' do
ActiveSupport.on_load :active_record do
if RubyLLM.config.use_new_acts_as
require 'ruby_llm/active_record/acts_as'
::ActiveRecord::Base.include RubyLLM::ActiveRecord::ActsAs
else
require 'ruby_llm/active_record/acts_as_legacy'
::ActiveRecord::Base.include RubyLLM::ActiveRecord::ActsAsLegacy
initializer 'ruby_llm.active_record' do
ActiveSupport.on_load :active_record do
if RubyLLM.config.use_new_acts_as
require 'ruby_llm/active_record/acts_as'
::ActiveRecord::Base.include RubyLLM::ActiveRecord::ActsAs
else
require 'ruby_llm/active_record/acts_as_legacy'
::ActiveRecord::Base.include RubyLLM::ActiveRecord::ActsAsLegacy

Rails.logger.warn(
"\n!!! RubyLLM's legacy acts_as API is deprecated and will be removed in RubyLLM 2.0.0. " \
"Please consult the migration guide at https://rubyllm.com/upgrading-to-1-7/\n"
)
Rails.logger.warn(
"\n!!! RubyLLM's legacy acts_as API is deprecated and will be removed in RubyLLM 2.0.0. " \
"Please consult the migration guide at https://rubyllm.com/upgrading-to-1-7/\n"
)
end
end
end
end

rake_tasks do
load 'tasks/ruby_llm.rake'
rake_tasks do
load 'tasks/ruby_llm.rake'
end
end
end
end