### Install Avo with One-Command App Template Source: https://docs.avohq.io/3.0/installation Executes a Rails app template from avohq.io to automate the installation of Avo in your application. This command streamlines the setup process by running all required steps. ```Shell bin/rails app:template LOCATION='https://avohq.io/app-template' ``` -------------------------------- ### One-Command Avo Installation via Rails App Template Source: https://docs.avohq.io/installation Executes a Rails app template to automate the installation of Avo, simplifying the setup process. This command runs all required steps to install Avo in your application. ```Shell bin/rails app:template LOCATION='https://avohq.io/app-template' ``` -------------------------------- ### Install Avo in Jumpstart Pro App Source: https://docs.avohq.io/3.0/installation Uses a specific app template to integrate Avo into an existing Jumpstart Pro application. This command provides a tailored installation for users of the Jumpstart Pro starter kit. ```Shell bin/rails app:template LOCATION=https://v3.avohq.io/templates/jumpstart-pro.template ``` -------------------------------- ### Install Avo in Jumpstart Pro Applications Source: https://docs.avohq.io/installation Applies a dedicated Rails app template to install Avo within Jumpstart Pro applications, providing a quick integration for this starter kit. ```Shell bin/rails app:template LOCATION=https://v3.avohq.io/templates/jumpstart-pro.template ``` -------------------------------- ### Example ChatGPT Prompt for Avo Resource Creation Source: https://docs.avohq.io/4.0/editor/chatgpt This example demonstrates a complete ChatGPT prompt for generating an Avo resource. It includes the guiding URL followed by a natural language request to create an Avo resource for a product model. ```bash https://avohq.io/llms.txt create an Avo resource for a product model ``` -------------------------------- ### Compile Avo Assets on Deploy from GitHub Source: https://docs.avohq.io/installation Enhances the `assets:precompile` Rake task to include `avo:build-assets`, ensuring Avo's assets are compiled during deployment when installing from GitHub. This is crucial for production environments. ```Ruby # Rakefile Rake::Task["assets:precompile"].enhance do Rake::Task["avo:build-assets"].execute end ``` -------------------------------- ### Add Avo Gem to Gemfile for Different Tiers Source: https://docs.avohq.io/installation Specifies the appropriate Avo gem to add to the Gemfile based on the desired tier (Community, Pro, or Advanced), including the source for paid tiers. After adding, run `bundle install`. ```Ruby # Add one of the following in your Gemfile depending on the tier you are on. # Avo Community gem "avo", ">= 3.2.1" # Avo Pro gem "avo", ">= 3.2.1" gem "avo-pro", ">= 3.2.0", source: "https://packager.dev/avo-hq/" # Avo Advanced gem "avo", ">= 3.2.1" gem "avo-advanced", ">= 3.2.0", source: "https://packager.dev/avo-hq/" ``` -------------------------------- ### Install Avo in Bullet Train App Source: https://docs.avohq.io/3.0/installation Uses a specific app template to integrate Avo into an existing Bullet Train application. This command simplifies the installation process for users of the Bullet Train starter kit. ```Shell bin/rails app:template LOCATION=https://v3.avohq.io/templates/bullet-train.template ``` -------------------------------- ### Install Avo in Bullet Train Applications Source: https://docs.avohq.io/installation Uses a specific Rails app template to integrate Avo into existing or new Bullet Train applications, streamlining the setup for this popular starter kit. ```Shell bin/rails app:template LOCATION=https://v3.avohq.io/templates/bullet-train.template ``` -------------------------------- ### Install Avo with RailsBytes Template Source: https://docs.avohq.io/2.0/installation This command provides a quick, one-liner method to install Avo into a Rails application using a pre-configured RailsBytes template, streamlining the initial setup. ```bash rails app:template LOCATION='https://avohq.io/app-template' ``` -------------------------------- ### Install avo-kanban gem dependencies Source: https://docs.avohq.io/3.0/kanban-boards Command to run `bundle install` to download and install the `avo-kanban` gem and its dependencies, ensuring all required gems are available in your project. ```bash bundle install ``` -------------------------------- ### Install Avo Kanban Gem Dependencies Source: https://docs.avohq.io/4.0/kanban-boards Runs the `bundle install` command to download and install the `avo-kanban` gem along with its required dependencies, such as `acts_as_list` and `hotwire_combobox`. ```bash bundle install ``` -------------------------------- ### Install Ruby Gems Source: https://docs.avohq.io/0.4.x/installation Run 'bundle install' in your terminal to download and install all the gems specified in your Gemfile, including the newly added Avo gem. ```Shell bundle install ``` -------------------------------- ### Install Avo in Jumpstart Pro using App Template Source: https://docs.avohq.io/4.0/installation Applies a dedicated Rails application template to install Avo within a Jumpstart Pro application, simplifying the integration. ```Shell bin/rails app:template LOCATION=https://v3.avohq.io/templates/jumpstart-pro.template ``` -------------------------------- ### One-Command Avo Installation using Rails App Template Source: https://docs.avohq.io/4.0/installation Executes a Rails application template from Avo HQ to automate the installation process, setting up all necessary configurations and files. ```Shell bin/rails app:template LOCATION='https://avohq.io/app-template' ``` -------------------------------- ### Rails Model Schema Information Example Source: https://docs.avohq.io/4.0/resources Example of a Rails model schema definition, typically found in `app/models/post.rb`. Avo can infer resource fields and associations based on this schema when generating resources, simplifying initial setup. ```ruby # == Schema Information # # Table name: posts # # id :bigint not null, primary key # name :string # body :text # is_featured :boolean # published_at :datetime # user_id :bigint # created_at :datetime not null # updated_at :datetime not null # status :integer default("draft") ``` -------------------------------- ### Generate Avo Initializer and Routes Source: https://docs.avohq.io/0.4.x/installation Execute the Avo install generator to create the necessary initializer file and automatically add Avo's routes to your Rails application's 'routes.rb' file. ```Shell bin/rails generate avo:install ``` -------------------------------- ### Manually Generated Avo Resource File Example Source: https://docs.avohq.io/4.0/resources Example of an Avo resource file generated manually using `bin/rails generate avo:resource`. It includes a basic `id` field and serves as a starting point for resource configuration, inferring the model from the resource name. ```ruby # app/avo/resources/post.rb class Avo::Resources::Post < Avo::BaseResource self.includes = [] # self.search = { # query: -> { query.ransack(id_eq: params[:q], m: "or").result(distinct: false) } # } def fields field :id, as: :id end end ``` -------------------------------- ### Install Avo in Bullet Train using App Template Source: https://docs.avohq.io/4.0/installation Uses a specific Rails application template to integrate Avo into an existing Bullet Train application, streamlining the setup process. ```Shell bin/rails app:template LOCATION=https://v3.avohq.io/templates/bullet-train.template ``` -------------------------------- ### Configure Zeitwerk Autoloading in Rails Source: https://docs.avohq.io/installation Ensures Rails applications use Zeitwerk for autoloading and load defaults for Rails 6.1 or higher, which is a requirement for Avo. This configuration is typically placed in `config/application.rb`. ```Ruby # config/application.rb config.autoloader = :zeitwerk config.load_defaults 6.1 # 6.1 or higher, depending on your rails version ``` -------------------------------- ### Example: Adding Stylesheet Asset with Avo AssetManager Source: https://docs.avohq.io/3.0/plugins A Ruby example demonstrating the use of `Avo.asset_manager.add_stylesheet` to include a CSS file, `/avo-kanban-assets/avo_kanban.css`, into Avo's layout. ```ruby Avo.asset_manager.add_stylesheet "/avo-kanban-assets/avo_kanban" ``` -------------------------------- ### Avo Default Pagination Configuration Example Source: https://docs.avohq.io/2.0/resources Example demonstrating the default pagination configuration for an Avo resource, showing how to set the type to `:default` and specify the page link size. ```ruby self.pagination = -> do { type: :default, size: [1, 2, 2, 1], } end ``` -------------------------------- ### Generate Avo Installation Files Source: https://docs.avohq.io/1.0/installation Execute this Rails generator command to set up Avo's initial configuration. It creates the Avo initializer file and integrates Avo into your application's routes.rb file, preparing the admin interface. ```Shell bin/rails generate avo:install ``` -------------------------------- ### Install Solid Cache Gem and Dependencies Source: https://docs.avohq.io/4.0/cache Installs the "solid_cache" gem and its dependencies using "bundle" or directly via "gem install". ```bash $ bundle ``` ```bash $ gem install solid_cache ``` -------------------------------- ### Installing Avo Pre-Release Gem Versions Source: https://docs.avohq.io/1.0/faq To test pre-release versions of the Avo gem, specify the exact version number in your `Gemfile`. This allows developers to try out new features or fixes before they are officially released to the `main` branch. ```Ruby # Gemfile # ... other gems gem 'avo', '1.19.1.pre.1' ``` -------------------------------- ### Avo action Control - Usage Examples Source: https://docs.avohq.io/2.0/customizable-controls Examples demonstrating how to use the `action` control to trigger different actions with various styling options. ```ruby action DisableAccount action ExportSelection, style: :text action PublishPost, color: :fuchsia, icon: "heroicons/outline/eye" ``` -------------------------------- ### Avo Action Generator Command Examples Source: https://docs.avohq.io/4.0/actions/generate Examples demonstrating various uses of the Avo action generator, including creating regular actions, standalone actions, and actions within specific namespaces. ```bash # Generate a regular action bin/rails generate avo:action mark_as_featured # Generate a standalone action bin/rails generate avo:action generate_monthly_report --standalone # Generate an action in a namespace bin/rails generate avo:action admin/approve_user ``` -------------------------------- ### Add Avo Gem to Gemfile Source: https://docs.avohq.io/3.0/installation Adds the appropriate Avo gem (Community, Pro, or Advanced) to your Rails application's Gemfile. This step is essential for including Avo in your project, with specific sources required for paid tiers. ```Ruby # Add one of the following in your Gemfile depending on the tier you are on. # Avo Community gem "avo", ">= 3.2.1" # Avo Pro gem "avo", ">= 3.2.1" gem "avo-pro", ">= 3.2.0", source: "https://packager.dev/avo-hq/" # Avo Advanced gem "avo", ">= 3.2.1" gem "avo-advanced", ">= 3.2.0", source: "https://packager.dev/avo-hq/" ``` -------------------------------- ### Configure Avo Home Path Source: https://docs.avohq.io/1.0/customization Sets the default path users are redirected to when clicking the Avo logo or navigating to `/avo`. This configuration also hides the 'Get started' sidebar item in the development environment. ```Ruby Avo.configure do |config| config.home_path = "/avo/dashboard" end ``` -------------------------------- ### Customize All Supported Avo View Components (v3.11.8+) Source: https://docs.avohq.io/resources Starting from Avo v3.11.8, this Ruby example shows how to replace a wider range of default components using string keys that match the original component names. This allows for more granular customization of Avo's UI. ```ruby self.components = { "Avo::Views::ResourceIndexComponent": Avo::Custom::ResourceIndexComponent, "Avo::Views::ResourceShowComponent": "Avo::Custom::ResourceShowComponent", "Avo::Views::ResourceEditComponent": "Avo::Custom::ResourceEditComponent", "Avo::Index::GridItemComponent": "Avo::Custom::GridItemComponent", "Avo::Index::ResourceMapComponent": "Avo::Custom::ResourceMapComponent", "Avo::Index::ResourceTableComponent": "Avo::Custom::ResourceTableComponent", "Avo::Index::TableRowComponent": "Avo::Custom::TableRowComponent" } ``` -------------------------------- ### Install Ruby Gems Source: https://docs.avohq.io/1.0/installation After adding new gems to the Gemfile, run this command to install all necessary dependencies for your Ruby on Rails application, including the Avo gem. This ensures all required libraries are available. ```Shell bundle install ``` -------------------------------- ### Add Avo Gem to Gemfile for Manual Installation Source: https://docs.avohq.io/4.0/installation Specifies the correct Avo gem to add to the Gemfile based on the desired Avo tier (Community, Pro, or Advanced), including the source for Pro and Advanced versions. ```Ruby # Add one of the following in your Gemfile depending on the tier you are on. # Avo Community gem "avo", ">= 3.2.1" # Avo Pro gem "avo", ">= 3.2.1" gem "avo-pro", ">= 3.2.0", source: "https://packager.dev/avo-hq/" # Avo Advanced gem "avo", ">= 3.2.1" gem "avo-advanced", ">= 3.2.0", source: "https://packager.dev/avo-hq/" ``` -------------------------------- ### Configure Rails for Zeitwerk Autoloading Source: https://docs.avohq.io/3.0/installation Ensures the Rails application uses Zeitwerk for autoloading and sets the default load version to 6.1 or higher, which is a prerequisite for Avo. This configuration is typically placed in `config/application.rb`. ```Ruby # config/application.rb config.autoloader = :zeitwerk config.load_defaults 6.1 # 6.1 or higher, depending on your rails version ``` -------------------------------- ### Retrieve LLM Integration Setup URL Source: https://docs.avohq.io/4.0/editor This snippet provides the URL to a compact text version of Avo's documentation, designed to help AI models like LLMs generate accurate Avo code. This URL can be used in various code editors for LLM integration. ```bash https://avohq.io/llms.txt ``` -------------------------------- ### Mount Avo to a Subdomain in Rails Routes Source: https://docs.avohq.io/installation Configures Rails routes to mount Avo at the root path (`/`) but only when accessed via a specific subdomain, using the `host` constraint in `routes.rb`. ```Ruby constraint host: 'avo' do mount_avo at: '/' end ``` -------------------------------- ### Install Avo Audit Logging Gem Source: https://docs.avohq.io/3.0/audit-logging/overview Adds the "avo-audit_logging" gem to your application's Gemfile from the specified source and then installs all bundle dependencies. ```bash gem "avo-audit_logging", source: "https://packager.dev/avo-hq/" ``` ```bash bundle install ``` -------------------------------- ### Examples of `action` Helper Usage in Avo (Ruby) Source: https://docs.avohq.io/3.0/customizable-controls This Ruby code provides various examples of using the `action` helper in Avo to display action buttons. It demonstrates how to trigger actions with and without arguments, and how to customize their appearance using `style`, `color`, and `icon` options. ```ruby action Avo::Actions::DisableAccount action Avo::Actions::DisableAccount, arguments: { hide_some_fields: true } action Avo::Actions::ExportSelection, style: :text action Avo::Actions::PublishPost, color: :fuchsia, icon: "heroicons/outline/eye" ``` -------------------------------- ### Mount Avo to a Subdomain in Rails Routes Source: https://docs.avohq.io/3.0/installation Configures Rails routes to mount Avo at the root path (`/`) but only when accessed via a specific subdomain, using the `host` constraint. This allows for flexible deployment scenarios. ```Ruby constraint host: 'avo' do mount_avo at: '/' end ``` -------------------------------- ### Example: Adding JavaScript Asset with Avo AssetManager Source: https://docs.avohq.io/3.0/plugins A Ruby example demonstrating the use of `Avo.asset_manager.add_javascript` to include a JavaScript file, `/avo-kanban-assets/avo_kanban.js`, into Avo's layout. ```ruby Avo.asset_manager.add_javascript "/avo-kanban-assets/avo_kanban" ``` -------------------------------- ### Avo Action Generator Usage Examples Source: https://docs.avohq.io/3.0/actions/generate Explore various examples of using the Avo action generator, including generating regular actions, standalone actions, and actions within specific namespaces for better organization. ```bash # Generate a regular action bin/rails generate avo:action mark_as_featured # Generate a standalone action bin/rails generate avo:action generate_monthly_report --standalone # Generate an action in a namespace bin/rails generate avo:action admin/approve_user ``` -------------------------------- ### Enhance Asset Precompilation for Avo GitHub Installation Source: https://docs.avohq.io/4.0/installation Modifies the `assets:precompile` Rake task to ensure Avo's assets are built during the deployment process when Avo is installed directly from GitHub. This is crucial for production environments. ```Ruby # Rakefile Rake::Task["assets:precompile"].enhance do Rake::Task["avo:build-assets"].execute end ``` -------------------------------- ### Install Ruby Gems with Bundler Source: https://docs.avohq.io/2.0/cache Executes Bundler to install all dependencies listed in the `Gemfile`. This command is crucial after adding new gems to ensure all required libraries are available in your project environment. ```bash $ bundle ``` -------------------------------- ### Ruby: Generating Action Link Without an Instantiated Resource Source: https://docs.avohq.io/3.0/actions/guides-and-tutorials This Ruby example illustrates how to generate an action link using `link_arguments` when a direct resource instance is not available, such as from a custom dashboard card. It shows creating a new resource instance on the fly to pass to the `link_arguments` method. ```ruby path, data = Avo::Actions::City::Update.link_arguments( resource: Avo::Resources::City.new(record: city) ) link_to "Update city", path, data: data ``` -------------------------------- ### Generate Action Link with Resource Instance Source: https://docs.avohq.io/4.0/actions/guides-and-tutorials Demonstrates how to use the `link_arguments` method within an Avo resource field to dynamically generate an action link for a specific record. It shows how to pass the resource instance and additional arguments to the action's `link_arguments` method to get the necessary path and data for `link_to`. ```ruby # app/avo/resources/city.rb class Avo::Resources::City < Avo::BaseResource field :name, as: :text, name: "Name (click to edit)", only_on: :index do path, data = Avo::Actions::City::Update.link_arguments( resource: resource, arguments: { cities: Array[resource.record.id], render_name: true } ) link_to resource.record.name, path, data: data end end ``` -------------------------------- ### Simplify Avo Action Registration in Resources (Ruby) Source: https://docs.avohq.io/3.0/upgrade This Ruby example illustrates the updated process for declaring actions within Avo resources. Previously, actions used in `show_controls` blocks required redundant declaration in the `actions` method. The 'After' section shows that this explicit declaration is no longer necessary, simplifying resource definitions. ```ruby # Before class Avo::Resources::Fish < Avo::BaseResource self.title = :name self.show_controls = -> do # In order to use it here action Avo::Actions::ReleaseFish, style: :primary, color: :fuchsia, arguments: { action_on_show_controls: "Will use this arguments" } end # 👇 Also declare it here 👇 def actions action Avo::Actions::ReleaseFish, style: :primary, color: :fuchsia, arguments: { action_on_show_controls: "Will use this arguments" } end end # After class Avo::Resources::Fish < Avo::BaseResource self.title = :name self.show_controls = -> do # In order to use it here action Avo::Actions::ReleaseFish, style: :primary, color: :fuchsia, arguments: { action_on_show_controls: "Will use this arguments" } end # 👇 No need to declare it here 👇 def actions end end ``` -------------------------------- ### Install and Configure Mobility Gem in Rails Source: https://docs.avohq.io/2.0/recipes/multilingual-content Instructions for integrating the `mobility` gem into a Ruby on Rails application for internationalization, covering gem installation, backend configuration, and model setup. Follow the official Mobility guide for best results. ```Ruby gem 'mobility', '~> 1.2.5' bundle install rails generate mobility:install # Example backend configuration (e.g., in an initializer or model) backend :key_value, type: :string # Add to your model extend Mobility translates :name ``` -------------------------------- ### Install Ruby gems with Bundler Source: https://docs.avohq.io/4.0/audit-logging/overview Executes `bundle install` to download and install the `avo-audit_logging` gem and its dependencies, ensuring all required packages are available for the application. ```bash bundle install ``` -------------------------------- ### Install Avo HTTP Resource Gem Source: https://docs.avohq.io/4.0/http-resources Instructions to add the `avo-http_resource` gem to your Gemfile and install it, enabling HTTP Resource functionality in Avo projects. ```ruby gem "avo-http_resource", source: "https://packager.dev/avo-hq/" ``` ```bash bundle install ``` -------------------------------- ### Install Solid Cache Gem Manually Source: https://docs.avohq.io/2.0/cache Provides an alternative method to install the `solid_cache` gem directly using the `gem install` command. This is useful for standalone installation or when not managing dependencies via Bundler. ```bash $ gem install solid_cache ``` -------------------------------- ### Quick Setup: Railsbytes Template for Helper Integration Source: https://docs.avohq.io/3.0/guides/use-own-helpers-in-resource-files A quick command to apply a Railsbytes template that sets up the necessary configuration for using helpers in Avo Resource files. ```ruby rails app:template LOCATION='https://railsbytes.com/script/V2Gsb9' ``` -------------------------------- ### Run Avo Audit Logging installer Source: https://docs.avohq.io/4.0/audit-logging/overview Generates the necessary migrations, resources, and controllers for the audit logging feature by running the `avo:audit_logging install` Rails generator. ```bash bin/rails generate avo:audit_logging install ``` -------------------------------- ### Enhance Rake Assets Precompile for Avo Source: https://docs.avohq.io/3.0/installation Modifies the Rakefile to ensure Avo's assets are built during the `assets:precompile` step. This is crucial when installing Avo directly from GitHub, as assets need to be compiled manually. ```Ruby # Rakefile Rake::Task["assets:precompile"].enhance do Rake::Task["avo:build-assets"].execute end ``` -------------------------------- ### Utilizing Avo Plugin Hooks (`avo_boot`, `avo_init`) Source: https://docs.avohq.io/3.0/plugins This Ruby example illustrates how to leverage Avo's `avo_boot` and `avo_init` hooks within a plugin. `avo_boot` is used for adding/removing concerns to Avo resources and managing global assets, while `avo_init` allows running code on each Avo request. ```ruby module Avo module FeedView class Engine < ::Rails::Engine isolate_namespace Avo::FeedView initializer "avo-feed-view.init" do ActiveSupport.on_load(:avo_boot) do Avo.plugin_manager.register :feed_view # Add some concerns Avo::Resources::Base.include Avo::FeedView::Concerns::FeedViewConcern # Remove some concerns Avo::Resources::Base.included_modules.delete(Avo::Concerns::SOME_CONCERN) # Add asset files to be loaded by Avo # These assets will be added to Avo's `application.html.erb` layout file Avo.asset_manager.add_javascript "/avo-advanced-assets/avo_advanced" Avo.asset_manager.add_stylesheet "/avo-kanban-assets/avo_kanban" end ActiveSupport.on_load(:avo_init) do # Run some code on each request Avo::FeedView::Current.something = VALUE end end end end end ``` -------------------------------- ### Examples of `action` Helper Usage in Avo (Ruby) Source: https://docs.avohq.io/4.0/customizable-controls This Ruby snippet provides various examples of using the `action` helper within Avo, demonstrating how to trigger actions with different styles, colors, icons, and arguments. It highlights that using `action` in customizable blocks only displays the button and does not automatically register the action. ```ruby action Avo::Actions::DisableAccount action Avo::Actions::DisableAccount, arguments: { hide_some_fields: true } action Avo::Actions::ExportSelection, style: :text action Avo::Actions::PublishPost, color: :fuchsia, icon: "heroicons/outline/eye" ``` -------------------------------- ### Avo Plugin Hooks API Reference Source: https://docs.avohq.io/3.0/plugins Reference documentation for the `avo_boot` and `avo_init` hooks, detailing their execution timing and primary use cases within Avo plugins. ```APIDOC Hook: avo_boot Description: Called when the parent Rails application boots up. Usage: Register scripts and stylesheets, add functionality to Avo, extend Avo classes (e.g., Avo::BaseResource, Avo::BaseController, Avo::ApplicationController). Hook: avo_init Description: Called on every request done inside Avo. Usage: Attach code to the Avo::App.context object or perform other per-request operations. ``` -------------------------------- ### Add Avo Gem to Gemfile Source: https://docs.avohq.io/1.0/installation This step adds the Avo gem to your Ruby on Rails project's Gemfile, making the Avo administration framework available for use. It's a prerequisite for installing and configuring Avo. ```Ruby gem 'avo' ``` -------------------------------- ### Example Custom Search Provider Implementation Source: https://docs.avohq.io/search This example demonstrates how to implement a custom search provider for an Avo resource, returning a hardcoded array of search results. This approach provides full control over the search output, but note that the results count will not be available with custom search providers. ```ruby class Avo::Resources::Project < Avo::BaseResource self.search = { query: -> do [ { _id: 1, _label: "Record One", _url: "https://example.com/1" }, { _id: 2, _label: "Record Two", _url: "https://example.com/2" }, { _id: 3, _label: "Record Three", _url: "https://example.com/3" } ] end } end ``` -------------------------------- ### Install Avo TailwindCSS Integration Source: https://docs.avohq.io/3.0/tailwindcss-integration This command automates the setup for TailwindCSS integration with Avo. It installs the `tailwindcss-rails` gem, generates Avo's specific Tailwind configuration, creates necessary stylesheet directories and files, updates the `Procfile.dev` for development watching, and adds a build script to `package.json`. ```bash bin/rails generate avo:tailwindcss:install ``` -------------------------------- ### Ruby: Abstract Example of Conditional Field Default in Avo Action Source: https://docs.avohq.io/3.0/actions/guides-and-tutorials This abstract Ruby snippet provides a conceptual example of how an Avo action's field default value can be made conditional based on a `previous_param`. It serves as a placeholder to illustrate the idea before a concrete implementation. ```ruby class Action def fields field :some_field, as: :hidden, default: -> { if previous_param == yes ? :yes : :no} end end ``` -------------------------------- ### Example Windsurf Prompt with Context7 Source: https://docs.avohq.io/4.0/editor/windsurf Illustrates how to leverage the configured Context7 MCP server by appending 'use context7' to a prompt. This directs Windsurf to use Context7's knowledge base when generating Avo code, such as creating a new Avo resource. ```bash create a new Avo resource for a product model. use context7 ``` -------------------------------- ### Install Avo TailwindCSS Integration Command Source: https://docs.avohq.io/4.0/tailwindcss-integration This `bin/rails` command automates the setup of TailwindCSS for Avo. It installs the `tailwindcss-rails` gem, generates Avo's specific `tailwind.config.js`, creates base, components, and utilities stylesheets, sets up a custom `tailwind.css` for further customization, and configures `Procfile.dev` and `package.json` for asset compilation. ```bash bin/rails generate avo:tailwindcss:install ``` -------------------------------- ### Install and Configure Mobility Gem for Translations Source: https://docs.avohq.io/1.0/recipes/multilingual-content This section outlines the steps to integrate the Mobility gem into a Ruby on Rails application to enable translatable fields. It covers adding the gem to the Gemfile, running bundle install, generating Mobility configurations, and configuring models with translatable attributes. ```Ruby gem 'mobility', '~> 1.2.5' ``` ```Shell bundle install ``` ```Shell rails generate mobility:install ``` ```Ruby backend :key_value, type: :string ``` ```Ruby extend Mobility ``` ```Ruby translates :name ``` -------------------------------- ### Example Custom Content in Avo Profile Menu Partial Source: https://docs.avohq.io/2.0/menu-editor Shows an example of how to render custom links within the ejected `_profile_menu_extra.html.erb` partial. It demonstrates using `Avo::ProfileItemComponent` to maintain consistency with Avo's styling. ```erb <%# Example link below %> <%#= render Avo::ProfileItemComponent.new label: 'Profile', path: '/profile', icon: 'user-circle' %> ``` -------------------------------- ### Configure Avo Main and Profile Menus Source: https://docs.avohq.io/4.0/menu-editor Illustrates how to set up both `main_menu` and `profile_menu` in Avo's initializer. It includes examples of adding dashboards, resources, tools, and custom links, along with visibility options for menu items. ```ruby # config/initializers/avo.rb Avo.configure do |config| config.main_menu = -> { section I18n.t("avo.dashboards"), icon: "dashboards" do dashboard :dashy, visible: -> { true } dashboard :sales, visible: -> { true } group "All dashboards", visible: false do all_dashboards end end section "Resources", icon: "heroicons/outline/academic-cap" do group "Academia" do resource :course resource :course_link end group "Blog" do resource :posts resource :comments (end group "Other" do resource :fish end end section "Tools", icon: "heroicons/outline/finger-print" do all_tools end group do link_to "Avo", path: "https://avohq.io" link_to "Google", path: "https://google.com", target: :_blank end } config.profile_menu = -> { link_to "Profile", path: "/profile", icon: "user-circle" } end ``` -------------------------------- ### Action Field Default Value with Conditional Logic Source: https://docs.avohq.io/4.0/actions/guides-and-tutorials An initial example showing how an action field's default value can be conditionally set based on a `previous_param`. ```ruby class Action def fields field :some_field, as: :hidden, default: -> { if previous_param == yes ? :yes : :no} end end ``` -------------------------------- ### Configure Avo Admin Homepage and Initializer Settings Source: https://docs.avohq.io/4.0/faq Demonstrates how to customize the default homepage for the Avo admin interface by setting `config.home_path` in the `config/initializers/avo.rb` file. The example also includes other essential Avo configuration options such as `root_path`, `license_key`, `id_links_to_resource`, and `set_context` for passing data to Avo. ```ruby # config/initializers/avo.rb Avo.configure do |config| config.root_path = '/avo' config.license_key = ENV['AVO_LICENSE_KEY'] config.id_links_to_resource = true config.home_path = '/avo/resources/posts' config.set_context do { foo: 'bar', user: current_user, params: request.params, } end end ``` -------------------------------- ### Example Avo Resource Creation Prompt with Context7 MCP Source: https://docs.avohq.io/4.0/editor/vscode This bash command demonstrates how to use the configured Context7 MCP server with an AI agent to generate a new Avo resource for a product model by appending `use context7` to the prompt, leveraging Context7's knowledge base. ```bash create a new Avo resource for a product model. use context7 ``` -------------------------------- ### Implement Search Query for Avo Resource Source: https://docs.avohq.io/4.0/associations/has_one Provides an example of configuring the `search_query` method within an Avo resource. This setup is crucial for the `searchable` option to function correctly on associated fields, allowing for custom search logic. ```ruby # app/avo/resources/course_link.rb class Avo::Resources::CourseLink < Avo::BaseResource self.search = { query: -> { query.ransack(id_eq: params[:q], link_cont: params[:q], m: "or").result(distinct: false) } } } ``` -------------------------------- ### Dynamically Hide Global Search in Avo Configuration Source: https://docs.avohq.io/search Starting from Avo version 3.13.5, `disabled_features` can be a callable block. This example shows how to dynamically hide the global search based on user roles, such as only for non-admin users, by accessing `current_user` within the block. ```ruby # config/initializers/avo.rb Avo.configure do |config| config.disabled_features = -> { current_user.is_admin? ? [] : [:global_search] } end ``` -------------------------------- ### Configure Avo Locale in Initializer (2.11+) Source: https://docs.avohq.io/2.0/upgrade Starting from Avo 2.11, the `locale` configuration option is read from the `avo.rb` initializer. This snippet shows how to set the locale, which is crucial to prevent crashes if your application relies on specific locale settings. ```ruby Avo.configure do |config| config.locale = :en # default is nil end ``` -------------------------------- ### Example Claude Prompt Using Context7 MCP Server Source: https://docs.avohq.io/4.0/editor/claude This bash command demonstrates how to prompt Claude to create an Avo resource for a product model, explicitly instructing it to use the configured Context7 MCP server for enhanced contextual understanding. ```bash create a new Avo resource for a product model. use context7 ``` -------------------------------- ### Basic Filters URL Parameter Change to encoded_filters Source: https://docs.avohq.io/3.0/upgrade To resolve a conflict with Dynamic Filters, the URL parameter for Basic Filters has been changed from `filters` to `encoded_filters`. This allows both Basic and Dynamic Filters to be used simultaneously in a URL. The examples show the URL structure before and after the change. ```md # Before https://example.com/avo/resources/users?filters[first_name][contains][]=Jason&page=1&filters=eyJBdm86OkZpbHRlcnM6OklzQWRtaW4iOlsiYWRtaW5zIl19 # After https://example.com/avo/resources/users?filters[first_name][contains][]=Jason&page=1&encoded_filters=eyJBdm86OkZpbHRlcnM6OklzQWRtaW4iOlsiYWRtaW5zIl19 ``` -------------------------------- ### Migrating Heading to Field Type in Avo Source: https://docs.avohq.io/3.0/avo-2-avo-3-upgrade The `heading` method is deprecated. It is now a field type with an ID, supporting text and HTML rendering. This snippet shows how to rename `heading` to `field` and use the `as: :heading` argument, including examples for simple text and HTML content. ```ruby # Before heading 'User Information' # After field :user_information, as: :heading # or... field :some_id, as: :heading, label: 'User Information' # Before heading '
User Information
', as_html: true # After field :some_id, as: :heading, as_html: true do '
User Information
' end ``` -------------------------------- ### Combined Usage of All Avo Menu Helpers Source: https://docs.avohq.io/4.0/menu-editor This example demonstrates how to use `all_dashboards`, `all_resources`, and `all_tools` together within a `section` and `group` structure. It's important to note that `all_resources` respects authorization rules, requiring `def index?` in your resource policy. ```ruby section "App", icon: "heroicons/outline/beaker" do group "Dashboards", icon: "dashboards" do all_dashboards end group "Resources", icon: "resources" do all_resources end group "All tools", icon: "tools" do all_tools end end ``` -------------------------------- ### Configure Avo Main and Profile Menus with Dashboards and Tools Source: https://docs.avohq.io/3.0/menu-editor Shows a more comprehensive example of configuring both `main_menu` and `profile_menu`. It includes `dashboard` with visibility options, `all_dashboards`, `all_tools`, and various resource groups. ```Ruby # config/initializers/avo.rb Avo.configure do |config| config.main_menu = -> { section I18n.t("avo.dashboards"), icon: "dashboards" do dashboard :dashy, visible: -> { true } dashboard :sales, visible: -> { true } group "All dashboards", visible: false do all_dashboards end end section "Resources", icon: "heroicons/outline/academic-cap" do group "Academia" do resource :course resource :course_link end group "Blog" do resource :posts resource :comments end group "Other" do resource :fish end end section "Tools", icon: "heroicons/outline/finger-print" do all_tools end group do link_to "Avo", path: "https://avohq.io" link_to "Google", path: "https://google.com", target: :_blank end } config.profile_menu = -> { link_to "Profile", path: "/profile", icon: "user-circle" } end ``` -------------------------------- ### Eager Load Attachments with self.includes in Avo Resources Source: https://docs.avohq.io/3.0/upgrade Attachments are no longer automatically eager loaded in Avo. To eager load attachments for a resource, use the self.includes option within your Avo resource definition. This example demonstrates eager loading a photo_attachment along with its blob. ```ruby class Avo::Resources::PhotoComment < Avo::BaseResource self.includes = [:user, [photo_attachment: :blob]] def fields field :user, as: :belongs_to field :photo, as: :file, is_image: true end ``` -------------------------------- ### Avo Resource Pagination Configuration Examples Source: https://docs.avohq.io/3.0/resources Illustrates various pagination configurations for Avo resources, including default pagination, countless pagination (disabling total count), and countless with an empty size for 'pageless' display. ```ruby self.pagination = -> do { type: :default, size: [1, 2, 2, 1] } end ``` ```ruby self.pagination = -> do { type: :countless } end ``` ```ruby self.pagination = -> do { type: :countless, size: [] } end ``` -------------------------------- ### Status Field: Defaulting failed_when and loading_when to Empty Arrays Source: https://docs.avohq.io/3.0/upgrade Due to issues with declaring defaults, the `failed_when` and `loading_when` options for status fields now default to empty arrays. If previous behavior is desired, these options must be explicitly added to the field definition, as shown in the example. ```ruby field :status, as: :status, failed_when: [:failed], loading_when: [:waiting, :running] ``` -------------------------------- ### Generate New Rails App with Avo Installation Commands Source: https://docs.avohq.io/4.0/technical-support Provides bash commands to quickly set up a new Rails application with different versions of Avo (standard, pro, advanced) pre-installed. These commands are useful for developers to create a clean environment for testing or troubleshooting Avo-related issues. ```bash # run this command to get a new Rails app with Avo installed rails new -m https://avo.cool/new.rb APP_NAME # run to install avo-pro rails new -m https://avo.cool/new-pro.rb APP_NAME # run to install avo-advanced rails new -m https://avo.cool/new-advanced.rb APP_NAME ``` -------------------------------- ### Update Avo Mounting Point in Rails Routes Source: https://docs.avohq.io/3.0/upgrade This snippet demonstrates how to update the `routes.rb` file to replace the obsolete `mount Avo::Engine` with the new `mount_avo` approach. It provides examples for both default and custom root paths, ensuring compatibility with the new mounting strategy. ```ruby # config/routes.rb Rails.application.routes.draw do mount Avo::Engine, at: Avo.configuration.root_path mount_avo end ``` ```ruby # config/routes.rb Rails.application.routes.draw do mount Avo::Engine, at: "custom/path" mount_avo at: "custom/path" end ``` -------------------------------- ### Quick Use Windsurf Command Source: https://docs.avohq.io/4.0/editor/windsurf Demonstrates how to quickly use Windsurf by typing a command in the chat window to fetch content from a specified URL for AI processing. ```bash @web https://avohq.io/llms.txt ``` -------------------------------- ### Comprehensive Avo Menu Configuration with Dashboards and Helpers Source: https://docs.avohq.io/2.0/menu-editor Shows a more comprehensive configuration for Avo's `main_menu` and `profile_menu`, including dashboards, resources, tools, and the use of `all_dashboards` and `all_tools` helpers for dynamic menu generation. ```ruby Avo.configure do |config| config.main_menu = -> { section I18n.t("avo.dashboards"), icon: "dashboards" do dashboard :dashy, visible: -> { true } dashboard :sales, visible: -> { true } group "All dashboards", visible: false do all_dashboards end end section "Resources", icon: "heroicons/outline/academic-cap" do group "Academia" do resource :course resource :course_link end group "Blog" do resource :posts resource :comments end group "Other" do resource :fish end end section "Tools", icon: "heroicons/outline/finger-print" do all_tools end group do link_to "Avo", path: "https://avohq.io" link_to "Google", path: "https://google.com", target: :_blank end } config.profile_menu = -> { link_to "Profile", path: "/profile", icon: "user-circle" } end ``` -------------------------------- ### Execute Bundle Update for Avo and Rails Gems (Bash) Source: https://docs.avohq.io/3.0/upgrade This Bash command provides the specific `bundle update` instruction to apply the Gemfile changes, updating `rails` and `avo-advanced` gems to their compatible versions. This step is crucial after modifying the `Gemfile` to ensure all dependencies are correctly installed. ```bash bundle update rails avo-advanced ``` -------------------------------- ### Download Avo LLMs.txt for Project-Level Copilot Setup Source: https://docs.avohq.io/4.0/editor/vscode This command downloads the Avo LLMs.txt file and saves it to the `.vscode/avo.md` path within your project, enabling GitHub Copilot to use it by default for code generation. ```bash curl -L https://avohq.io/llms.txt --create-dirs -o .vscode/avo.md ``` -------------------------------- ### Configuring Avo Admin Panel Homepage Source: https://docs.avohq.io/3.0/faq Illustrates how to set a custom homepage for the Avo admin section by configuring `config.home_path` in the `config/initializers/avo.rb` file, redirecting users to a specified path upon navigating to `/avo`. ```Ruby # config/initializers/avo.rb Avo.configure do |config| config.root_path = '/avo' config.license_key = ENV['AVO_LICENSE_KEY'] config.id_links_to_resource = true config.home_path = '/avo/resources/posts' config.set_context do { foo: 'bar', user: current_user, params: request.params, } end end ``` -------------------------------- ### New Avo Resource Row Controls Placement Configuration Source: https://docs.avohq.io/3.0/upgrade This snippet demonstrates the new recommended way to configure resource row controls placement. It provides examples for both global configuration in `config/initializers/avo.rb` and resource-specific configuration within an Avo resource class, using the updated `resource_row_controls_config` and `row_controls_config` properties. ```ruby # config/initializers/avo.rb Avo.configure do |config| config.resource_row_controls_config = { placement: :left, } end ``` ```ruby # app/avo/resources/user.rb class Avo::Resources::User < Avo::BaseResource self.row_controls_config = { placement: :left, } end ``` -------------------------------- ### Example Avo Resource Creation Prompt in Zed Agent Mode Source: https://docs.avohq.io/4.0/editor/zed Illustrates how to use the configured Context7 MCP server in Zed's Agent Mode to generate Avo code, by appending 'use context7' to your prompt. ```bash create a new Avo resource for a product model. use context7 ``` -------------------------------- ### Action link_arguments Method Update for Argument Encoding Source: https://docs.avohq.io/3.0/upgrade The `Action link_arguments` method now handles argument encoding and encryption internally. Users only need to pass arguments as a hash, and the returned path will already include the encoded arguments. This example demonstrates how to use the updated `link_arguments` method within a field definition. ```ruby field :name, as: :text, filterable: true, name: "name (click to edit)", only_on: :index do arguments = Base64.encode64 Avo::Services::EncryptionService.encrypt( message: { cities: Array[resource.record.id], render_name: true }, purpose: :action_arguments ) arguments = { cities: Array[resource.record.id], render_name: true } path, data = Avo::Actions::City::Update.link_arguments( resource: resource, arguments: arguments ) link_to resource.record.name, path, data: data end ``` -------------------------------- ### Generate New Rails Application with Avo Pre-installed Source: https://docs.avohq.io/3.0/technical-support These commands allow users to quickly scaffold a new Rails application with Avo already integrated. They are particularly useful for creating isolated reproduction repositories to help the Avo team troubleshoot issues, or for rapidly starting new projects with specific Avo editions (standard, Pro, or Advanced). ```bash # run this command to get a new Rails app with Avo installed rails new -m https://avo.cool/new.rb APP_NAME # run to install avo-pro rails new -m https://avo.cool/new-pro.rb APP_NAME # run to install avo-advanced rails new -m https://avo.cool/new-advanced.rb APP_NAME ``` -------------------------------- ### Ruby: Accessing URL Parameters from `request.referer` in Avo Action Source: https://docs.avohq.io/3.0/actions/guides-and-tutorials This Ruby code demonstrates how to access and parse URL parameters from `request.referer` within an Avo action's field definition. It shows how to extract parameters, convert them to a hash, and use them to dynamically set a field's default value, for example, checking for a 'hey=ya' parameter. ```ruby class Action def fields # Accessing the parameters passed from the parent view field :some_field, as: :hidden, default: -> { # Parsing the request referer to extract parameters parent_params = URI.parse(request.referer).query.split("&").map { |param| param.split("=")}.to_h.with_indifferent_access # Checking if the `hei` parameter equals `ya` if parent_params[:hey] == 'ya' :yes else :no end } end end ``` -------------------------------- ### Setting Avo Admin Homepage in Initializer Source: https://docs.avohq.io/faq Demonstrates how to configure a custom homepage for the Avo admin section by setting the `config.home_path` in the `config/initializers/avo.rb` file. It also shows other common Avo configuration options. ```ruby # config/initializers/avo.rb Avo.configure do |config| config.root_path = '/avo' config.license_key = ENV['AVO_LICENSE_KEY'] config.id_links_to_resource = true config.home_path = '/avo/resources/posts' config.set_context do { foo: 'bar', user: current_user, params: request.params } end end ```