Hi everyone, From time to time I'm experiencing an...
# avo-2
n
Hi everyone, From time to time I'm experiencing an issue with Avo where I cannot see the relationships(has_many) that I've set in the resources file. I only see a loading animation that keeps running forever like one of the images attached. At the same time, the search bar colapses(attached) and there is an error on the Chrome console(attached). I've already tried to clear the cache and switch to a different browser, but the problem still shows up from time to time. Has anyone faced this issue before?
l
Hey Arthur, do you have the associations mapped to the model file as well?
you should have those added too
n
Yes, I do. Here is the relevant parts. quiz_resource.rb
Copy code
field :questions, as: :has_many
  field :email_accounts, as: :has_and_belongs_to_many,
    attach_scope: -> { query.where(operation: parent.operation).where(quiz: true).order(name: :asc) }
quiz.rb
Copy code
belongs_to :blog
  belongs_to :operation
  has_many :questions
  has_many :answers, through: :questions
  has_and_belongs_to_many :email_accounts
  has_one_attached :rules
  has_prefix_id :q, minimum_length: 6
l
from the screenshots I see that you have this issue on production
hmmm
n
Yes, it doesn't happen in the dev environment
l
can you click the
avo.base.js:1
part and let me know what you got there?
(from the last screenshot to the right)
n
In Chrome nothing happens. In FIrefox I get this error from the image
And when I click I get this:
l
I think you can click on the script name
ok. then let's try soemthign else
n
This is the full file
Copy code
You are loading Turbo from a <script> element inside the <body> element. This is probably not what you meant to do!

        Load your application’s JavaScript bundle inside the <head> element instead. <script> elements in <body> are evaluated with each page change.

        For more information, see: https://turbo.hotwired.dev/handbook/building#working-with-script-elements

        ——
        Suppress this warning by adding a "data-turbo-suppress-warning" attribute to: %s
l
can you open the source code (right click on the page and click the "view page source")
you should get something like this
n
Copy code
<script>
//<![CDATA[

  window.Avo = window.Avo || { configuration: {} }
  Avo.configuration.timezone = 'UTC'
  Avo.configuration.root_path = '/admin/avo'
  Avo.configuration.search_debounce = '300'
  Avo.configuration.cookies_key = 'avo'

//]]>
l
ok. can you show me the routes file where you load Avo?
n
Copy code
Rails.application.routes.draw do
  devise_for :users

  devise_scope :user do
    require "sidekiq/web"
    require "sidekiq/cron/web"
    authenticated :user do
      mount Sidekiq::Web => "admin/sidekiq"
      mount Avo::Engine, at: Avo.configuration.root_path
    end
  end

  resources :quizzes_presentations, only: %i[new show create]
  get "/:id", to: "quizzes_presentations#show"

  root to: "quizzes_presentations#new"
end
l
and the
root_path
in the `avo.rb`initializer?
n
Copy code
config.root_path = "admin/avo"
l
this is it
... I think
can you try and set it to either
/admin
or
/avo
?
that should be one single segment that starts with
/
n
Yes, let me try that and deploy again. I'll send you a feedback as soon as I'm done.
l
you can have Avo under
/admin/avo
using the routes file
n
It looks better now. Thank you for your support 👊
l
ah-mazing
thanks for troubleshooting it with me
n
Hi @lemon-wall-20836 , the problem started again. I've deployed the latest version of avo and it worked fine for a while. Now it's again not working and giving me the same error. Do you know what else could I try?
l
hmmm
it's weird that "it started again" 🙂
n
Yes, it is. Maybe there is something to do with how I build the containers or something else, but it's failing in an intermittent way.
Let me review everything first and I'll come back to this again.
l
that could be it. maybe a container is caching the old code somehow?
n
That can be
l
if it's intermitent, 99.99% it's not from Avo
n
Makes sense. I'll find out what is going on.
m
There really seems to be a performance issue with version 2.30, I had that perception but without running any benchmarks. It could even be a flow improvement, if it doesn't already exist, of course, perform some performance tests to compare with the previous release
l
Hmmm, there is one thing that we did for 2.30
We changed the default caching strategy
It’s turned pff by default
in order to bring back that behavior you shoudl enable the option in the initializer
Copy code
ruby
Avo.configure do |config|
  config.cache_resources_on_index_view = true
end
sorry for not communicating this better
**Correction**: we haven’t pushed that piece of code into 2.30. Sorry about that.
m
thanks again, Adrian. I will test this configuration