ActiveAdmin

Add & configure ActiveAdmin to your Rails app
Icons/chart bar
Used 128 times
Created by
B Benjamin Darcet

Usage

Run this command in your Rails app directory in the terminal:

rails app:template LOCATION="https://railsbytes.com/script/zyvsMx"
Template Source

Review the code before running this template on your machine.

run "bundle add activeadmin"
run "bundle add bcrypt"
if yes?("Do you want to install Devise?(prefered)[y/n]") && !defined?(Devise)
  run "bundle add devise"
  rails_command "generate active_admin:install --use_webpacker"
else
  model = ask("What is the user model you want to use for Active Admin? (ex: User)")
  rails_command "generate active_admin:install #{model.capitalize} --use_webpacker" if model
end
rails_command "generate active_admin:webpacker"
rails_command "db:migrate"

while yes?("Do you want to add an other model to ActiveAdmin?[y/n]") do
  model = ask('Model name (ex: Post or MyPost):')
  if model
    rails_command "g active_admin:resource #{model}"
  end
end

while yes?("Do you want to use other gems?[y/n]") do
  if yes?("Do you want to install CanCancan?[y/n]") && !defined?(CanCancan)
    run "bundle add cancancan"
  end
  if yes?("Do you want to install Draper?[y/n]") && !defined?(Draper)
    run "bundle add draper"
  end
  if yes?("Do you want to install Pundit?[y/n]") && !defined?(Pundit)
    run "bundle add pundit"
  end
end
  
Comments

Sign up or Login to leave a comment.