Skip to content

Commit c92234d

Browse files
committed
Register supported adapters, fixes loading gem from local path
without this for some reason, rails thinks it needs CRuby gems such as pg gem, etc.
1 parent 55b7307 commit c92234d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/arjdbc.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,20 @@
1212
rescue LoadError => e
1313
warn "activerecord-jdbc-adapter failed to load railtie: #{e.inspect}"
1414
end if defined?(Rails) && ActiveRecord::VERSION::MAJOR >= 3
15+
16+
ActiveSupport.on_load(:active_record) do
17+
ActiveRecord::ConnectionAdapters.register(
18+
"sqlite3", "ActiveRecord::ConnectionAdapters::SQLite3Adapter", "arjdbc/sqlite3/adapter"
19+
)
20+
ActiveRecord::ConnectionAdapters.register(
21+
"postgresql", "ActiveRecord::ConnectionAdapters::PostgreSQLAdapter", "arjdbc/postgresql/adapter"
22+
)
23+
ActiveRecord::ConnectionAdapters.register(
24+
"mysql2", "ActiveRecord::ConnectionAdapters::Mysql2Adapter", "arjdbc/mysql/adapter"
25+
)
26+
end
1527
else
1628
warn "activerecord-jdbc-adapter is for use with JRuby only"
1729
end
1830

19-
require 'arjdbc/version'
31+
require 'arjdbc/version'

0 commit comments

Comments
 (0)