You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an issue when run my app in production RAILS_ENV=production. I have a initializer file which add a custom method
# frozen_string_literal: true# config/initializers/kaminari_active_record_relation_with_limit.rbrequire'kaminari'moduleKaminari# Active Record specific page scope methods implementationsmoduleActiveRecordRelationWithLimitMAX_COUNT_LIMIT=10_000# This is a modified version of# https://github.com/kaminari/kaminari/blob/c5186f5d9b7f23299d115408e62047447fd3189d/kaminari-activerecord/lib/kaminari/activerecord/active_record_relation_methods.rb#L17-L41# that limit the COUNT query to a configurable value to avoid query timeouts.# The default limit value is 10,000 recordsdeftotal_count_with_limit(column_name=:all,options={})# :nodoc:# more code hereend# prepend this module Kaminari::ActiveRecordRelationMethods.prepend(self)endend
In test & development everything works as expected but when I want to compile assets got following error.
deployer@1e89e413e91b:/usr/src/app$ RAILS_ENV=production rails assets:precompile
rails aborted!
NameError: uninitialized constant Kaminari::ActiveRecordRelationMethods
Kaminari::ActiveRecordRelationMethods.prepend(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Did you mean? Kaminari::ActiveRecordRelationWithLimit
/usr/src/app/config/initializers/kaminari_active_record_relation_with_limit.rb:39:in `<module:ActiveRecordRelationWithLimit>'/usr/src/app/config/initializers/kaminari_active_record_relation_with_limit.rb:6:in `<module:Kaminari>'/usr/src/app/config/initializers/kaminari_active_record_relation_with_limit.rb:4:in `<main>'/usr/src/app/config/environment.rb:7:in `<main>'
Tasks: TOP => environment
(See full trace by running task with --trace)
In development (rails c)
irb(main):002:0> Company.page.total_count_with_limit(:id, limit: 2)
Company Count (0.6ms) SELECT COUNT(count_column) FROM (SELECT "companies"."id" AS count_column FROM "companies" LIMIT $1) subquery_for_count [["LIMIT", 3]]
=> 1
irb(main):003:0>
Any thoughts?
The text was updated successfully, but these errors were encountered:
I have an issue when run my app in production
RAILS_ENV=production
. I have a initializer file which add a custom methodIn test & development everything works as expected but when I want to compile assets got following error.
In development (
rails c
)Any thoughts?
The text was updated successfully, but these errors were encountered: