### Install Avo Kanban Gem Source: https://context7_llms Step-by-step instructions for installing the `avo-kanban` gem, including adding it to the Gemfile, running bundle install, generating necessary resources and controllers, and applying database migrations. ```Ruby gem "avo-kanban", source: "https://packager.dev/avo-hq/" ``` ```Bash bundle install ``` ```Bash rails generate avo:kanban install ``` ```Bash rails db:migrate ``` -------------------------------- ### Install and Configure Mobility Gem for Translations Source: https://context7_llms Step-by-step guide to install the "mobility" gem, including adding it to the Gemfile, running bundle install, generating mobility files, and configuring a model for translatable fields. ```Ruby gem 'mobility', '~> 1.2.5' ``` ```Shell bundle install rails generate mobility:install ``` ```Ruby backend :key_value, type: :string extend Mobility translates :name ``` -------------------------------- ### Install Avo using RailsBytes Template Source: https://github.com/avo-hq/avo This command uses a RailsBytes template to quickly set up a new Rails application with Avo pre-configured. It's the recommended way to get started quickly with Avo. ```Shell rails app:template LOCATION='https://avohq.io/app-template' ``` -------------------------------- ### Install Avo Using One-Command App Template Source: https://context7_llms This command provides a streamlined way to install Avo in a Rails application using a predefined app template. It automates all the necessary steps for a quick setup. ```shell bin/rails app:template LOCATION='https://avohq.io/app-template' ``` -------------------------------- ### Install Avo HTTP Resource Gem Dependencies Source: https://context7_llms After adding the `avo-http_resource` gem to the Gemfile, run `bundle install` to download and install the gem and its dependencies, making HTTP Resources available in your Avo project. ```bash bundle install ``` -------------------------------- ### Basic Authentication Example in Avo ApplicationController Source: https://context7_llms Shows a conceptual example of how `http_basic_authenticate_with` would be directly applied to `Avo::ApplicationController` for basic authentication. ```Ruby class Avo::ApplicationController < ::ActionController::Base http_basic_authenticate_with name: "adrian", password: "password" # More methods here end ``` -------------------------------- ### Install Avo in Jumpstart Pro Applications Source: https://context7_llms This command provides a specific app template for installing Avo into existing Jumpstart Pro applications. It simplifies the integration process for users of the Jumpstart Pro starter kit. ```shell bin/rails app:template LOCATION=https://v3.avohq.io/templates/jumpstart-pro.template ``` -------------------------------- ### Install AvoHQ using RailsBytes Template Source: https://github.com/avo-hq/avo Use this command to quickly set up AvoHQ in your Rails application by applying the official RailsBytes template. This streamlines the initial configuration process. ```Ruby rails app:template LOCATION='https://avohq.io/app-template' ``` -------------------------------- ### Install Avo Audit Logging Gem Source: https://context7_llms Adds the `avo-audit_logging` gem to your Gemfile, specifying the source, and then runs `bundle install` to install dependencies. ```bash gem "avo-audit_logging", source: "https://packager.dev/avo-hq/" ``` ```bash bundle install ``` -------------------------------- ### Run Avo Audit Logging Installer Source: https://context7_llms After installing the `avo-audit_logging` gem, this command executes the installer, which automatically generates required migrations, resources, and controllers. This prepares your application for audit logging functionality. ```bash bin/rails generate avo:audit_logging install ``` -------------------------------- ### Avo Resource Default Pagination Example Source: https://context7_llms An example of configuring Avo resource pagination with default settings using a block. This setup typically includes page numbers and a total count. ```Ruby self.pagination = -> do { type: :default, size: [1, 2, 2, 1], } end ``` -------------------------------- ### Install Solid Cache Gem Source: https://context7_llms Execute these commands to install the `solid_cache` gem after adding it to your Gemfile, either via `bundle` or `gem install`. ```bash $ bundle ``` ```bash $ gem install solid_cache ``` -------------------------------- ### Chartkick Development Environment Setup Source: https://github.com/ankane/chartkick Instructions for setting up a local development environment for Chartkick. This includes cloning the repository, installing Ruby dependencies, and running tests. ```Shell git clone https://github.com/ankane/chartkick.git cd chartkick bundle install bundle exec rake test ``` -------------------------------- ### Examples of Avo Action Generator Commands Source: https://context7_llms This section provides various examples of using the `avo:action` generator. It shows how to generate a regular action, a standalone action, and an action within a specific namespace. ```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 ``` -------------------------------- ### Install Active Storage and Run Database Migrations Source: https://edgeguides.rubyonrails.org/active_storage_overview.html Executes Rails commands to install Active Storage, which sets up configuration files, and then runs database migrations to create the necessary tables: active_storage_blobs, active_storage_attachments, and active_storage_variant_records. ```Shell $ bin/rails active_storage:install $ bin/rails db:migrate ``` -------------------------------- ### Complete Avo Scope Definition Example Source: https://context7_llms A comprehensive example demonstrating the configuration of an Avo scope, combining dynamic name, description, query logic, and visibility rules within a single class definition. ```ruby # app/avo/scopes/even_id.rb class Avo::Scopes::EvenId < Avo::Advanced::Scopes::BaseScope # Please see the performance note above if you're using `scoped_query` self.name = -> { "Even (#{scoped_query.count})" } # This will compute the description based on the resource name self.description = -> { "Only #{resource.name.downcase.pluralize} that have an even ID" } # This will scope the query to only even IDs self.scope = -> { query.where("#{resource.model_key}.id % 2 = ?", "0") } # Only show this scope to admins self.visible = -> { current_user.admin? } end ``` -------------------------------- ### Mapkick Development Setup Source: https://github.com/ankane/mapkick Commands to set up the Mapkick development environment, including cloning the repository, installing Ruby dependencies, and running tests. ```Shell git clone https://github.com/ankane/mapkick.git cd mapkick bundle install bundle exec rake test ``` -------------------------------- ### Example Avo Profile Item Component in ERB Partial Source: https://context7_llms An example of how to render an Avo Profile Item Component within the `_profile_menu_extra.html.erb` partial, demonstrating how to add custom links. ```ERB <%# Example link below %> <%#= render Avo::ProfileItemComponent.new label: 'Profile', path: '/profile', icon: 'user-circle' %> ``` -------------------------------- ### cURL Example for Basic Resource Creation Source: https://context7_llms cURL command demonstrating how to send a POST request to create a new team with basic name and URL fields. ```bash curl -X POST /api/v1/teams \ -H "Content-Type: application/json" \ -d '{ "team": { "name": "Mobile Team", "url": "https://mobile.company.com" } }' ``` -------------------------------- ### cURL Example for Resource Listing with Query Parameters Source: https://context7_llms cURL command demonstrating how to use pagination and sorting query parameters when fetching a list of teams. ```bash GET /api/v1/teams?page=2&per_page=10&sort_by=name&sort_direction=asc ``` -------------------------------- ### Set up Chartkick Development Environment Source: https://github.com/ankane/chartkick This snippet provides the necessary shell commands to clone the Chartkick repository, navigate into the project directory, install dependencies using Bundler, and run the test suite to verify the setup. ```Shell git clone https://github.com/ankane/chartkick.git cd chartkick bundle install bundle exec rake test ``` -------------------------------- ### Run Bundle Install for Avo API Gem Source: https://context7_llms After adding the avo-api gem to your Gemfile, this command should be executed in your terminal. It installs the newly added gem and its dependencies, making the Avo REST API functionality available in your application. ```Bash bundle install ``` -------------------------------- ### Start Rails Development Server with Bundler Watcher Source: https://github.com/rails/jsbundling-rails Convenience script to concurrently start the Rails server and the JavaScript (and optionally CSS) build watchers, streamlining the development setup. ```Shell ./bin/dev ``` -------------------------------- ### Render Minimal Avo::PanelComponent Source: https://context7_llms A basic example of rendering the `Avo::PanelComponent` with only a body, demonstrating that all options are optional. ```erb <%= render Avo::PanelComponent.new do |c| %> <% c.with_body do %> Something here. <% end %> <% end %> ``` -------------------------------- ### Setup Mapkick Development Environment Source: https://github.com/ankane/mapkick Provides a sequence of shell commands to set up the Mapkick development environment. This includes cloning the repository, navigating into the project directory, installing Ruby dependencies with Bundler, and running the test suite. ```shell git clone https://github.com/ankane/mapkick.git cd mapkick bundle install bundle exec rake test ``` -------------------------------- ### cURL Example for Resource Creation with Associations Source: https://context7_llms cURL command demonstrating how to send a POST request to create a new team, including an associated `admin_id`. ```bash curl -X POST /api/v1/teams \ -H "Content-Type: application/json" \ -d '{ "team": { "name": "Backend Team", "url": "https://backend.company.com", "admin_id": 5 } }' ``` -------------------------------- ### JavaScript: Initiating Direct Uploads with Active Storage Source: https://edgeguides.rubyonrails.org/active_storage_overview.html Demonstrates how to create a `DirectUpload` instance, handle file uploads, and manage progress using the `@rails/activestorage` library. It includes an example of passing custom headers for authentication. ```JavaScript import { DirectUpload } from "@rails/activestorage" class Uploader { constructor(file, url, token) { const headers = { 'Authentication': `Bearer ${token}` } // INFO: Sending headers is an optional parameter. If you choose not to send headers, // authentication will be performed using cookies or session data. this.upload = new DirectUpload(file, url, this, headers) } uploadFile(file) { this.upload.create((error, blob) => { if (error) { // Handle the error } else { // Use the with blob.signed_id as a file reference in next request } }) } directUploadWillStoreFileWithXHR(request) { request.upload.addEventListener("progress", event => this.directUploadDidProgress(event)) } directUploadDidProgress(event) { // Use event.loaded and event.total to update the progress bar } } ``` -------------------------------- ### Example Usage of Avo::Current.view_context Source: https://context7_llms This Ruby snippet demonstrates how to use the `view_context` attribute available through `Avo::Current`. It shows an example of calling `link_to` on the `view_context` to generate an HTML link. ```ruby view_context.link_to "Avo", "https://avohq.io" ``` -------------------------------- ### Install and Migrate Active Storage Source: https://guides.rubyonrails.org/active_storage_overview.html Execute these Rake tasks to set up Active Storage, which includes generating configuration files and creating the necessary database tables: `active_storage_blobs`, `active_storage_attachments`, and `active_storage_variant_records`. ```Shell $ bin/rails active_storage:install $ bin/rails db:migrate ``` -------------------------------- ### Run Bundle Install Source: https://avohq.io/templates/jumpstart-pro This Ruby command executes 'bundle install' within a clean Bundler environment to ensure all newly added gems are installed correctly after modifying the Gemfile. ```Ruby Bundler.with_unbundled_env { run "bundle install" } ``` -------------------------------- ### Example Incoming HTTP GET Request Source: https://guides.rubyonrails.org/routing.html Illustrates a typical incoming HTTP GET request for a user resource with a specific ID. This request is processed by the Rails router to determine the appropriate controller action. ```HTTP GET /users/17 ``` -------------------------------- ### Configure Avo Main and Profile Menus with Visibility Options Source: https://context7_llms A comprehensive example showing configuration for both `main_menu` and `profile_menu` in `config/initializers/avo.rb`. It includes sections, groups, resources, dashboards with `visible` options, and helpers like `all_dashboards` and `all_tools`, along with external links. ```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 ``` -------------------------------- ### Set Up Hashid-Rails Development Environment Source: https://github.com/jcypret/hashid-rails Provides commands to initialize the development environment for the Hashid-Rails gem. `bin/setup` installs all necessary dependencies, and `bin/console` launches an interactive Ruby console for testing and experimentation. ```Shell bin/setup bin/console ``` -------------------------------- ### Combined Usage of `all_` Helpers in Ruby Source: https://context7_llms Provides a consolidated example demonstrating the use of `all_dashboards`, `all_resources`, and `all_tools` helpers within a single menu section and groups. It also includes a warning about `all_resources` respecting authorization rules. ```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 } ``` -------------------------------- ### Render Avo::PanelComponent with Title, Description, Tools, and Body Source: https://context7_llms Example of rendering the `Avo::PanelComponent` in an ERB template, demonstrating how to set a title, description, and include content in both the tools and body sections. ```erb <%= render Avo::PanelComponent.new(title: @product.name, description: @product.description) do |c| %> <% c.with_tools do %> <%= a_link(@product.link, icon: 'heroicons/solid/academic-cap', style: :primary, color: :primary) do %> View product <% end %> <% end %> <% c.with_body do %>

Product information

Style: shiny

<% end %> <% end %> ``` -------------------------------- ### Avo Date/Time Filter Modes and Value Formatting Source: https://context7_llms Explains the `:range` and `:single` modes for Avo's date/time filter, detailing how the value is formatted in `:range` mode. It also provides a Ruby example to parse the date range string into start and end dates. ```APIDOC Default value: :range Possible values: - :range - Allows users to choose a start and end date, making it suitable for applications that require a time span, such as reservations or scheduling. - In :range mode the `value` will be formatted as "2024-08-13 to 2024-08-16". - :single - Limits the selection to a single date, perfect for use cases where only one specific day needs to be selected, such as an appointment or event date. ``` ```Ruby date_1, date_2 = value.split(" to ") ``` -------------------------------- ### Avo Action Helper Usage Examples Source: https://context7_llms Demonstrates various ways to use the `action` helper in Avo, showing how to define actions with or without arguments, and apply styling options like `style`, `color`, and `icon`. ```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 REST API Endpoints for Resources Source: https://context7_llms This section outlines the standard RESTful API endpoints automatically generated by Avo for each resource, using `teams` as an example. It lists the HTTP methods (GET, POST, PATCH, PUT, DELETE) and their corresponding paths for listing, creating, showing, updating, and deleting records. ```APIDOC GET /api/v1/teams # List all teams POST /api/v1/teams # Create a new team GET /api/v1/teams/:id # Show a specific team PATCH /api/v1/teams/:id # Update a team PUT /api/v1/teams/:id # Update a team DELETE /api/v1/teams/:id # Delete a team ``` -------------------------------- ### Mount Sidekiq Web UI to an Existing Rack Application Source: https://github.com/mperham/sidekiq/wiki/Monitoring This example demonstrates how to integrate the Sidekiq Web UI into an existing Rack application. It uses `Rack::URLMap` to map the root path to a Sinatra application (as an example) and the `/sidekiq` path to the Sidekiq Web UI, allowing both to run under the same Rack process. ```Ruby require 'your_app' require 'sidekiq/web' run Rack::URLMap.new('/' => Sinatra::Application, '/sidekiq' => Sidekiq::Web) ``` -------------------------------- ### Install Avo TailwindCSS Integration Source: https://context7_llms This command automates the setup of TailwindCSS for Avo applications. It installs the `tailwindcss-rails` gem, generates Avo's specific Tailwind configuration, creates necessary stylesheet directories, customizes `app/assets/stylesheets/avo/tailwind.css`, enhances `Procfile.dev` for development watching, and adds a build script to `package.json`. ```bash bin/rails generate avo:tailwindcss:install ``` -------------------------------- ### Ruby: Basic Encryption and Decryption with Avo EncryptionService Source: https://context7_llms Provides a usage example of the Avo::Services::EncryptionService for encrypting and decrypting a simple string. It highlights the importance of matching the `purpose` during both operations. ```Ruby secret_encryption = Avo::Services::EncryptionService.encrypt(message: "Secret string", purpose: :demo) # "x+rnETtClF2cb80PtYzlULnVB0vllf+FvwoqBpPbHWa8q6vlml5eRWrwFMcYrjI6--h2MiT1P5ctTUjwfQ--k2WsIRknFVE53QwXADDDJw==" Avo::Services::EncryptionService.decrypt(message: secret_encryption, purpose: :demo) # "Secret string" ``` -------------------------------- ### cURL Example for Full Resource Update (PUT) Source: https://context7_llms cURL command demonstrating how to send a PUT request to fully update a team's name, URL, and description. ```bash curl -X PUT /api/v1/teams/1 \ -H "Content-Type: application/json" \ -d '{ "team": { "name": "Completely Updated Team", "url": "https://new.company.com", "description": "New description" } }' ``` -------------------------------- ### Run Solid Cache Database Migrations Source: https://context7_llms Generate and run the necessary database migrations for Solid Cache to set up its tables and infrastructure. ```bash $ bin/rails solid_cache:install:migrations ``` ```bash $ bin/rails db:migrate ``` -------------------------------- ### Bi-directional `has_one` and `belongs_to` Association Example Source: https://guides.rubyonrails.org/association_basics.html Illustrates a bi-directional association setup in Rails, where `Supplier` `has_one` `Account` and `Account` `belongs_to` `Supplier`, including a validation example for the `Account` model. ```Ruby # app/models/supplier.rb class Supplier < ApplicationRecord has_one :account end # app/models/account.rb class Account < ApplicationRecord validates :terms, presence: true belongs_to :supplier end ``` -------------------------------- ### Avo Resource Tool: Sample Panel Component Integration Source: https://context7_llms Provides an example of a resource tool partial (`post_info.html.erb`) demonstrating the integration of `Avo::PanelComponent` with `tools` and `body` slots, showing how to structure custom resource views. ```erb
<%= render Avo::PanelComponent.new title: "Post info" do |c| %> <% c.with_tools do %> <%= a_link('/avo', icon: 'heroicons/solid/academic-cap', style: :primary) do %> Dummy link <% end %> <% end %> <% c.with_body do %>

🪧 This partial is waiting to be updated

You can edit this file here app/views/avo/resource_tools/post_info.html.erb.

The resource tool configuration file should be here app/avo/resource_tools/post_info.rb.

<% # In this partial, you have access to the following variables: # tool # @resource # @resource.model # form (on create & edit pages. please check for presence first) # params # Avo::Current.context # current_user %>
<% end %> <% end %>
``` -------------------------------- ### Ruby: Example Avo Dashboard Definition Source: https://context7_llms Shows a basic structure for an Avo dashboard class, defining its unique ID, display name, description, grid column layout, and the list of cards it contains. ```Ruby class Avo::Dashboards::MyDashboard < Avo::Dashboards::BaseDashboard self.id = 'my_dashboard' self.name = 'Dashy' self.description = 'The first dashbaord' self.grid_cols = 3 def cards card Avo::Cards::ExampleMetric card Avo::Cards::ExampleAreaChart card Avo::Cards::ExampleScatterChart card Avo::Cards::PercentDone card Avo::Cards::AmountRaised card Avo::Cards::ExampleLineChart card Avo::Cards::ExampleColumnChart card Avo::Cards::ExamplePieChart card Avo::Cards::ExampleBarChart divider label: "Custom partials" card Avo::Cards::ExampleCustomPartial card Avo::Cards::MapCard end end ``` -------------------------------- ### Avo REST API Index Response Format Source: https://context7_llms This JSON example illustrates the typical response structure for an Avo REST API GET /api/v1/teams request, which retrieves a list of all team records. It includes an array of records, each with team details, and a pagination object providing metadata about the current page, total pages, and record counts. ```JSON { "records": [ { "id": 1, "name": "Development Team", "url": "https://dev.company.com", "logo": "https://logo.clearbit.com/dev.company.com?size=180" }, { "id": 2, "name": "Marketing Team", "url": "https://marketing.company.com", "logo": "https://logo.clearbit.com/marketing.company.com?size=180" } ], "pagination": { "page": 1, "per_page": 25, "total_pages": 1, "total_count": 2, "has_next_page": false, "has_prev_page": false } } ``` -------------------------------- ### Configure Avo Resource Pagination as Block Source: https://context7_llms This example demonstrates how to configure pagination settings for an Avo resource using a Ruby block, allowing for dynamic or complex pagination configurations. ```Ruby self.pagination = -> do { type: :default, size: [1, 2, 2, 1], } end ``` -------------------------------- ### Set BUNDLE_PACKAGER__DEV in Dockerfile Source: https://context7_llms Defines the BUNDLE_PACKAGER__DEV environment variable and runs bundle install within a Docker image build process, ensuring dependencies are installed. ```dockerfile ENV BUNDLE_PACKAGER__DEV=$BUNDLE_PACKAGER__DEV RUN bundle install COPY . /app ``` -------------------------------- ### Avo REST API Show Record Response Format Source: https://context7_llms This JSON example demonstrates the response structure for an Avo REST API GET /api/v1/teams/:id request, which retrieves details for a specific team record. It contains a single record object with the team's attributes, including nested related data like admin and team_members counts. ```JSON { "record": { "id": 1, "name": "Development Team", "url": "https://dev.company.com", "logo": "https://logo.clearbit.com/dev.company.com?size=180", "admin": { "id": 5, "label": "John Doe" }, "team_members": { "count": 12 } } } ``` -------------------------------- ### Install Pundit in a New Rails Application Source: https://context7_llms Before generating policies, Pundit must be installed in a new Rails application. This command sets up the necessary Pundit infrastructure, including an ApplicationPolicy. ```Ruby bin/rails g pundit:install ``` -------------------------------- ### Configure Day Start for Groupdate in Ruby Source: https://github.com/ankane/groupdate Shows how to globally set the start of the day for Groupdate or apply it directly to a `group_by_day` query. This allows defining when a "day" begins for aggregation purposes, for example, at 2 AM. ```Ruby Groupdate.day_start = 2 # 2 am - 2 am ``` ```Ruby User.group_by_day(:created_at, day_start: 2).count ``` -------------------------------- ### Setup Mapkick Static Development Environment Source: https://github.com/ankane/mapkick-static This snippet provides the necessary shell commands to clone the Mapkick Static repository, navigate into the project directory, install required dependencies using Bundler, and execute the test suite. These steps are essential for anyone looking to contribute to the project's codebase. ```shell git clone https://github.com/ankane/mapkick-static.git cd mapkick-static bundle install bundle exec rake test ``` -------------------------------- ### Hook into Avo Plugin Lifecycle with `avo_boot` and `avo_init` Source: https://context7_llms Demonstrates how Avo plugins can hook into Avo's lifecycle events using `ActiveSupport.on_load`. It shows examples of adding/removing concerns and managing assets during `avo_boot`, and running code on each request with `avo_init`. ```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 ``` -------------------------------- ### Avo Resource Countless Pagination Example Source: https://context7_llms This example demonstrates how to configure Avo resource pagination to be 'countless'. This disables the total item count on the index page, which can improve performance for very large datasets. ```Ruby self.pagination = -> do { type: :countless } end ``` -------------------------------- ### Install acts_as_list Gem via Command Line Source: https://github.com/brendon/acts_as_list Install the acts_as_list gem directly from the command line using the gem install command. This is useful for standalone installation or for development environments. ```Shell gem install acts_as_list ``` -------------------------------- ### Example S3 CORS Configuration for Direct Uploads Source: https://edgeguides.rubyonrails.org/active_storage_overview.html This JSON snippet provides an example CORS configuration for Amazon S3, allowing PUT requests from a specified origin with necessary headers for Active Storage direct uploads. ```JSON [ { "AllowedHeaders": [ "Content-Type", "Content-MD5", "Content-Disposition" ], "AllowedMethods": [ "PUT" ], "AllowedOrigins": [ "https://www.example.com" ], "MaxAgeSeconds": 3600 } ] ``` -------------------------------- ### Shell commands to set up Avo on root path Source: https://context7_llms These shell commands illustrate the process of creating a new Rails application, installing Avo using a template, and then modifying the `avo.rb` initializer to set Avo's root path to `/` using `sed`. ```Bash rails new avo-root-path cd avo-root-path bin/rails app:template LOCATION='https://avohq.io/app-template' sed -i '' "s|config.root_path = '/avo'|config.root_path = '/'|" config/initializers/avo.rb ``` -------------------------------- ### Avo Scope Option Transformation Examples Source: https://context7_llms Provides examples of how different `--scope` values are transformed into Ruby module namespaces for ejected Avo components. This clarifies the naming conventions for scoped components. ```APIDOC `--scope users_admins` -> `Avo::Views::UsersAdmins::ResourceIndexComponent` `--scope users/admins` -> `Avo::Views::Users::Admins::ResourceIndexComponent` ``` -------------------------------- ### Setup Database Schemas for MySQL and PostgreSQL Source: https://github.com/rails/solid_cache Configure the database schemas for MySQL and PostgreSQL by running the `db:setup` command with the `TARGET_DB` environment variable. This prepares the databases for testing. ```Shell $ TARGET_DB=mysql bin/rails db:setup $ TARGET_DB=postgres bin/rails db:setup ``` -------------------------------- ### Example Avo RoleResource file Source: https://context7_llms This Ruby code provides an example of a `RoleResource` file for Avo. It defines the title field as `name` and sets up a `has_and_belongs_to_many` association with `accounts`, allowing roles to be managed and linked to users. ```Ruby class RoleResource < Avo::BaseResource self.title = :name self.includes = [] field :name, as: :text field :accounts, as: :has_and_belongs_to_many end ``` -------------------------------- ### AvoHQ Heading Field: Definition Examples Source: https://context7_llms Illustrates different ways to define a `Heading` field in AvoHQ, which acts as a visual separator. Examples include using a field ID, a static label, and a computed label. ```ruby field :user_information, as: :heading ``` ```ruby field :some_id, as: :heading, label: "user information" ``` ```ruby field :some_id, as: :heading do "user information" end ``` -------------------------------- ### Running Sidekiq Web UI Standalone with Rack Source: https://github.com/mperham/sidekiq/wiki/Monitoring Sample code to run Sidekiq::Web as a standalone Rack application. It demonstrates configuring a cookie store for session management and emphasizes sharing the secret key in multi-process deployments for consistent sessions. ```Ruby # This is sidekiq_web.ru # Run with `bundle exec rackup sidekiq_web.ru` or similar. require "securerandom" require "rack/session" require "sidekiq/web" # In a multi-process deployment, all Web UI instances should share # this secret key so they can all decode the encrypted browser cookies # and provide a working session. # Rails does this in /config/initializers/secret_token.rb secret_key = SecureRandom.hex(32) use Rack::Session::Cookie, secret: secret_key, same_site: true, max_age: 86400 run Sidekiq::Web ``` -------------------------------- ### Render All Tools with `all_tools` Helper in Ruby Source: https://context7_llms Demonstrates how to render all Avo tools within a menu group. ```ruby section "App", icon: "heroicons/outline/beaker" do group "All tools", icon: "tools" do all_tools end } ``` -------------------------------- ### Install Avo in Bullet Train Applications Source: https://context7_llms This command provides a specific app template for installing Avo into existing Bullet Train applications. It streamlines the integration process for users of the Bullet Train starter kit. ```shell bin/rails app:template LOCATION=https://v3.avohq.io/templates/bullet-train.template ``` -------------------------------- ### Example Azure Storage CORS Configuration for Direct Uploads Source: https://edgeguides.rubyonrails.org/active_storage_overview.html This XML snippet provides an example CORS configuration for Azure Storage, allowing PUT requests from a specified origin with specific headers required for Active Storage direct uploads. ```XML https://www.example.com PUT Content-Type, Content-MD5, x-ms-blob-content-disposition, x-ms-blob-type 3600 ``` -------------------------------- ### Install Acts As List Gem via Command Line Source: https://github.com/brendon/acts_as_list Install the `acts_as_list` gem globally or for your current Ruby environment using the command line. This method is useful for quick testing or if you're not using a Gemfile. ```Shell gem install acts_as_list ``` -------------------------------- ### Example Avo Locale File Structure for pt-BR Source: https://context7_llms Illustrates the structure of a complete Avo locale file for Portuguese (Brazil), demonstrating how `field_translations` and `resource_translations` are organized. This example clarifies the expected YAML structure for comprehensive localization. ```yaml # config/locales/avo.pt-BR.yml pt-BR: avo: field_translations: file: zero: 'arquivos' one: 'arquivo' other: 'arquivos' resource_translations: user: zero: 'usuários' one: 'usuário' other: 'usuários' ``` -------------------------------- ### Avo Boolean Group Database Payload Example Source: https://context7_llms Provides an example of the hash structure stored in the database for an Avo `BooleanGroup` field. This hash contains string keys representing roles or permissions with boolean values indicating their status. ```JSON { "admin": true, "manager": true, "writer": true } ``` -------------------------------- ### Avo Action Helper Usage Examples Source: https://docs.avohq.io/3.0/customizable-controls.html Demonstrates various ways to use the `action` helper in Avo, including basic usage, passing arguments, and applying styles or icons to action buttons. ```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" ``` -------------------------------- ### Set Up Mapkick-static Development Environment Source: https://github.com/ankane/mapkick-static Provides step-by-step instructions for developers to set up their local environment for contributing to the Mapkick-static project. This includes cloning the repository, installing Ruby dependencies using Bundler, and running the test suite. ```Shell git clone https://github.com/ankane/mapkick-static.git cd mapkick-static bundle install bundle exec rake test ``` -------------------------------- ### Install Avo Audit Logging Gem Source: https://context7_llms This snippet provides the necessary `Gemfile` entry and `bundle install` command to add the `avo-audit_logging` gem to your Ruby on Rails project. This gem is essential for integrating Avo's comprehensive audit logging capabilities. ```bash gem "avo-audit_logging", source: "https://packager.dev/avo-hq/" ``` ```bash bundle install ``` -------------------------------- ### Single Table Inheritance (STI) Model Definition Example Source: https://context7_llms This Ruby code demonstrates a basic Single Table Inheritance (STI) setup in Rails, showing a `User` base class and a `SuperUser` subclass, illustrating how Rails casts models in STI scenarios. ```ruby # app/models/user.rb class User < ApplicationRecord end # app/models/super_user.rb class SuperUser < User end # User.all.map(&:class) => [User, SuperUser] ``` -------------------------------- ### Avo Dashboard: Overview Source: https://avohq.io/templates/jumpstart-pro Configures an Avo dashboard named 'Overview' that organizes and displays various metric cards, including revenue metrics for different periods, user count, and active subscriptions. ```Ruby class Avo::Dashboards::Overview < Avo::Dashboards::BaseDashboard self.id = "overview" self.name = "Overview" self.grid_cols = 4 def cards divider label: "Revenue" card Avo::Cards::TotalRevenue, arguments: { period: :this_month }, label: "This month" card Avo::Cards::TotalRevenue, arguments: { period: :last_month }, label: "Last month" card Avo::Cards::TotalRevenue, arguments: { period: :last_12_months }, label: "Last 12 months" card Avo::Cards::TotalRevenue divider card Avo::Cards::UsersCount card Avo::Cards::ActiveSubscriptions end end ``` -------------------------------- ### APIDOC: `all_resources` Helper Arguments Source: https://context7_llms Documents the arguments for the `all_resources` helper. ```APIDOC all_resources: exclude: (Array, optional) – A list of resource names to be excluded. ``` -------------------------------- ### Ruby Active Record Model Definitions for Query Examples Source: https://guides.rubyonrails.org/active_record_querying.html These Ruby Active Record model definitions (Author, Book, Customer, Order, Review, Supplier) serve as foundational examples throughout the guide, illustrating associations, scopes, and enums for demonstrating various query interface functionalities. ```Ruby class Author < ApplicationRecord has_many :books, -> { order(year_published: :desc) } end class Book < ApplicationRecord belongs_to :supplier belongs_to :author has_many :reviews has_and_belongs_to_many :orders, join_table: "books_orders" scope :in_print, -> { where(out_of_print: false) } scope :out_of_print, -> { where(out_of_print: true) } scope :old, -> { where(year_published: ...50.years.ago.year) } scope :out_of_print_and_expensive, -> { out_of_print.where("price > 500") } scope :costs_more_than, ->(amount) { where("price > ?", amount) } end class Customer < ApplicationRecord has_many :orders has_many :reviews end class Order < ApplicationRecord belongs_to :customer has_and_belongs_to_many :books, join_table: "books_orders" enum :status, [:shipped, :being_packed, :complete, :cancelled] scope :created_before, ->(time) { where(created_at: ...time) } end class Review < ApplicationRecord belongs_to :customer belongs_to :book enum :state, [:not_reviewed, :published, :hidden] end class Supplier < ApplicationRecord has_many :books has_many :authors, through: :books end ``` -------------------------------- ### Example Usage of Markdown Help in Avo Field Source: https://context7_llms This example demonstrates how to apply the `markdown_help` helper function to the `help` attribute of an Avo field. It showcases various Markdown elements like headings, paragraphs, code blocks, and lists, which will be rendered as formatted HTML in the Avo UI. ```Ruby field :description_copy, as: :markdown, help: markdown_help(<<~MARKDOWN # Dog ## Cat ### bird paragraph about hats **bold hat** ~~~ class Ham def wow puts "wow" end end ~~~ `code thinger` - one - two - three MARKDOWN ) ``` -------------------------------- ### Set Up Development Environment and Run Tests for Active Median Source: https://github.com/ankane/active_median Instructions for setting up the development environment for the Active Median project, including cloning the repository, installing dependencies, and running tests against various database systems like Postgres, SQLite, MariaDB/MySQL, SQL Server, and MongoDB. ```Shell git clone https://github.com/ankane/active_median.git cd active_median bundle install # Postgres createdb active_median_test bundle exec rake test # SQLite ADAPTER=sqlite3 BUNDLE_GEMFILE=gemfiles/sqlite3.gemfile bundle exec rake test # MariaDB and MySQL (for MySQL, install the extension first) mysqladmin create active_median_test ADAPTER=mysql2 BUNDLE_GEMFILE=gemfiles/mysql2.gemfile bundle exec rake test # SQL Server docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=YourStrong!Passw0rd' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2022-latest docker exec -it /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P YourStrong\!Passw0rd -C -Q "CREATE DATABASE active_median_test" ADAPTER=sqlserver BUNDLE_GEMFILE=gemfiles/sqlserver.gemfile bundle exec rake test # MongoDB BUNDLE_GEMFILE=gemfiles/mongoid7.gemfile bundle exec rake test ``` -------------------------------- ### Avo Pagination Default Configuration Example Source: https://docs.avohq.io/3.0/resources.html Provides a code example demonstrating the default configuration for Avo resource pagination, setting the type to `:default` and specifying a page size array for link display. ```ruby self.pagination = -> do { type: :default, size: [1, 2, 2, 1], } end ``` -------------------------------- ### JSON Success Response for Resource Deletion (200 OK) Source: https://context7_llms Example JSON response indicating a successful deletion of a resource. ```json { "message": "Team deleted successfully" } ```