rails active admin setup
What is the active admin ?
Active Admin is a framework for creating administration style interfaces. It abstracts common business application patterns to make it simple for developers to implement beautiful and elegant interfaces with very little effort.
For this tutorial, I set up Two models.
rails generate scaffold Post title:string description:string rails generate scaffold Comment content:text post:references Migrate the database:
$ rails db:migrateThe models have the following associations.
app/models/post.rb
class Post < ActiveRecord::Base
has_many :comments
endapp/models/comment.rb
class Comment < ActiveRecord::Base
belongs_to :post
endActive Admin is a Ruby on Rails plugin for generating administration style interfaces. To set it up in your Rails project, you'll need to follow these steps:
Add the Devise gem to your Gem file:
gem 'devise','~>4.8', '=> 4.8.1'Add the Active Admin gem to your Gem file:
gem 'activeadmin' Run this commend to install the gem.
$ bundle install
Run the generator to create the required files:
$ rails generate active_admin:installMigrate the database:
$ rails db:migrate Visit http://localhost:3000/admin and log in using:
You`re on your brand new Active Admin dashboard
To register your first model , and this comment in the terminal.
$ rails generate active_admin:resource [Post]rails generate active_admin:resource [Comment]This creates a file at app/admin/post.rb and app/admin/comment.rb for configuring the resource. Refresh your web
browser to see the interface.
Comments
Post a Comment