- Read Tutorial
- Watch Guide Video
In this section, we are going to work on creating an admin dashboard. We'll start by adding two gems called administrate
and bourbon
to the Gemfile
.
# Gemfile gem 'administrate' , '~>0.2.2' gem 'bourbon'
Next, type bundle
, so that all the dependencies are installed in the application.
Next, we'll install administrate
with the command:
rails generate administrate:install
This command created quite a few things for us. It created two folders called controllers
and dashboards
. Inside these directories it created an application_controller.rb
, user_controller.rb
and post_controller.rb
.
Now, we need to install bourbon
. For that, open the file application.css.scss
and update the file so it matches this:
/* app/assets/stylesheets/application.css.scss */ @import "bootstrap-sprockets"; @import "bootstrap"; @import "posts.scss"; @import "gritter"; @import "bourbon";
Let's start the rails server and open localhost:3000/admin
in the browser.
You may notice that this page doesn't require a user to sign in, so we'll have to fix this later.
If you browse through the links, you'll see that it displays all of the users and posts along, it also includes features such as pagination. There are no admin users, so this page is empty.
You can also edit posts, and even assign a post to a particular user like this:
There is even a search feature right at the top.
This is a relatively new, but well configured admin gem and is a solid alternatives to admin dashboards such as RailsAdmin
and ActiveAdmin
.
As great as the dashboard is, we still need to customize and fix a few things, which we'll do in the subsequent guides.