# Upgrade guide

# Upgrade from 2.5 to 2.6

# Change the way the cards run their queries

We made a change to the way you build your queries in cards. Instead of using the query block, you can use the query method.

The change should be straightforward and shouldn't really impact the logic of your card. You'll have access to all the same data as before.











 
 
 
 

 
 
 
 


class AmountRaised < Avo::Dashboards::MetricCard
  self.id = "amount_raised"
  self.label = "Amount raised"
  # self.description = "Some description"
  # self.cols = 1
  # self.initial_range = 30
  # self.ranges = [7, 30, 60, 365, "TODAY", "MTD", "QTD", "YTD", "ALL"]
  self.prefix = "$"
  # self.suffix = ""

  # Before
  query do
    result 9001
  end

  # Current
  def query
    result 9001
  end
end

# Upgrade from 2.4 to 2.5

# Change the way the scope is declared in associations

We changed how we add scopes to associations to make the API more flexible and extendable. You have to append query. to the scope.

Also, you now have access to a few more pieces of information inside that block. You can use the parent, which is the actual parent record (User in the example below) of that association.
















 





 


# app/models/comment.rb
class Comment < ApplicationRecord
  belongs_to :user, optional: true

  scope :starts_with, -> (prefix) { where('LOWER(body) LIKE ?', "#{prefix}%") }
end

# app/models/user.rb
class User < ApplicationRecord
  has_many :comments
end

# app/avo/resource/user_resource.rb
class UserResource < Avo::BaseResource
  # Version before v2.5.0
  field :comments, as: :has_many, scope: -> { starts_with :a }
end

# app/avo/resource/user_resource.rb
class UserResource < Avo::BaseResource
  # Version after v2.5.0
  field :comments, as: :has_many, scope: -> { query.starts_with :a }
end

# Upgrade from 1.x to 2.0

# Update the gem

Run bundle update avo to update your gem. If you have a Pro license, follow this guide (opens new window) to update your license.

# Update your sidebar & profile partials

We changed some of the remaining partials to view_components.

# View components

Renamed the following view components:

  • NavigationLinkComponent to SidebarItemComponent.
  • NavigationHeadingComponent to SidebarHeadingComponent.

# Translations

We added the following tags:

  • avo.details

Removed the following tags:

  • avo.resource_details
  • avo.update_item

# Controllers

Renamed RelationsController to AssociationsController