With Lipsiadmin 5.0 the menu is cached, this because for example we want to build a category tree like:

# in account_access.rb
project.menu "My Customers", "/backend/accounts/customer.js" do |submenu|
  submenu.add "Of Category" do |cat_menu|
    generate_categories_tree(Category.roots, cat_menu)
  end
  submenu.add "-"
  submenu.add :new, "/backend/accounts/new/customer"
end

private
  def self.generate_categories_tree(categories, menu)
    for category in categories
      menu.add "#{category.text} (#{category.accounts.size})", "/backend/accounts/#{category.id}.js" do |sub_menu|
        generate_categories_tree(category.children, sub_menu)
      end
    end # End of For
  end

Be we don't want to regenerate for each request the menu, will be expensive in terms of cpu/ram and require some times if we have a lot of categories.

So we think a simple way for cache them.

The cache will be flushed if we restart our webserver. But we don't want do that so:

My Rail Project$ $ script/generate observer account_access

The open your account_access_observer.rb with your prefered editor and add some like:

class AccountAccessObserver < ActiveRecord::Observer
    observe :account, :category

    def after_save(record); expire_cache(record); end
    def after_destroy(record); expire_cache(record); end

  private
    def expire_cache(record)
      # Clean our cache only for users that can access
      # to the admin panel
      Account.all(:conditions => {:role => 'administrator'}).each do |account|
        RAILS_DEFAULT_LOGGER.debug "  Expire cache for: #{account.full_name}"
        Lipsiadmin::AccessControl::Base.cache[account.id] = nil
      end
    end
  end

Now environment.rb add:

config.active_record.observers = :account_access_observer

That's all refresh your page and now you can see new menus!