# Installation
# Requirements
- Ruby on Rails > 6.0
- Ruby > 2.6
# Installing Avo
- Add
gem 'avo'to yourGemfile - Run
bundle install. - Run
bin/rails generate avo:installto generate the initializer and add Avo to theroutes.rbfile. - Generate an Avo Resource
# Authorization
You probably would not want to allow anyone access to Avo. If you're using devise (opens new window) in your app, use this block to filter out requests to it in your routes.rb file.
authenticate :user do mount Avo::Engine => '/avo' endCopied!
You may also add custom user validation such as user.admin? to only permit a subset of users to your Avo instance.
authenticate :user, -> user { user.admin? } do mount Avo::Engine => '/avo' endCopied!
# authorize_with method
Alternatively you can user the authorize_with config attribute. It takes a block and evaluates it in Avo's ApplicationController as a before_action.
Avo.configure do |config| config.authenticate_with do authenticate_admin_user end endCopied!
# Customize the current_user method
If you're not using devise (opens new window) for authentication you may customize the current_user method to something else. The current_user_method key takes a block parameter (shorthand or full block).
Avo.configure do |config| config.current_user_method(&:current_admin) endCopied!
Using the block notation:
Avo.configure do |config| config.current_user_method do current_admin end endCopied!
# Adding the license key
After you purchase an Avo license add it to your config/initializers/avo.rb file along with changing the license type from community to pro.
Avo.configure do |config| config.license = 'pro' config.license_key = '************************' # or use ENV['AVO_LICENSE_KEY'] endCopied!