Domanda

I installato la gemma active_admin in un lavoro applicazione Rails. Dopo aver fatto questo, l'applicazione notevolmente rallentato. Ci vogliono circa 4-5 secondi per ottenere una nuova pagina. Alcune funzionalità è rotto.

E 'questo forse a causa di amministrazione attiva affidamento su disposizione testamentaria e conflitti che sorgono perché ho il mio autenticazione? Avevo già un modello User con metodi come 'current_user' e il segno nelle caratteristiche.

In altre parole, non è vero suppone di utilizzare di amministrazione attiva a meno di utilizzare escogitare per l'autenticazione? Non vedo niente di questo nella documentazione.

Sono on Rails 3.1, database PostgreSQL, se quello che conta.

È stato utile?

Soluzione

The slow down in Rails 3.1 is a known issue that is mostly due to the the way Active Admin interacts with the new Asset Pipeline. The issue is - as far as I'm aware - only present when running in development mode (so when you deploy to production it should go away).

There is also a memory leak issue in development that might have a performance impact. But my personal experience is that this isn't the main performance killer.

To overcome the slow environment issue in development, one quick fix is to install the rails-dev-tweaks gem. This will prevent Rails from regenerating assets when the incoming request is an asset request (images, css, js etc.).

As to your second question: Active Admin only works with devise. But it is entirely possible to use a different authentication mechanism in your frontend and only rely on Devise in Active Admin. You should of cause ensure that Devise and your own authentication does not conflict. You can change devise and Active Admin to use a different method for retrieving the current user. By default Active Admin uses current_admin_user - not current_user. You can change the authentication settings for Active Admin in config/initializers/active_admin.rb. For more info, read the authentication documentation.

Altri suggerimenti

If your admin models have belongs_to and has_many relationships and the default behavior of ActiveAdmin will practically load your database into RAM. It is recommended that you add only the filters truly needed.

Specifying the exact fields for each filter collection will also greatly reduce query execution time and memory footprint. By default, ActiveAdmin is looking for :id and :name attributes. One query I applied this to reduced from several seconds to .7ms. YES!!

e.g.

filter :account, collection: Account.unscoped.select(‘id, name’)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top