Shalafister
Shalafister

Reputation: 399

Easy Admin panel with Rails

I have created a web page with RoR and i am using auth system that i wrote. Now i would like to create an admin panel, where i can see the user info etc..

I am not sure but what i though is to add a column name to auth system like admin? giving a default name false. Then if the admin? is true admin panel opens instead of the web page login.

I wonder if i can use the same auth system so in order to login to page it logs in to admin panel.

But in the controller it will check if admin? is true for every user, i am not sure about the burden in terms of the system requirments as it will check every user.

And i know there are other gems for admin panel but its fine i can design it. I am just not sure which way is the efficient way.

Upvotes: 0

Views: 164

Answers (2)

Vinicius Martinson
Vinicius Martinson

Reputation: 95

In addition to that, you may try Rails_Admin, which provides an easy-to-use interface for managing your data.

And I've considered to use this gem for my project, which is a huge database, so it seems to very helpful.

Upvotes: 0

Phil
Phil

Reputation: 2800

The burden on the system will be negligible. It depends a little bit upon how your auth system is configured, but I am assuming that you give the user a token when he/she is properly logged in.

When the user first tries to sign in, you should check if they are an admin. At this point, if they are, then you can sign them in as an admin, also storing that information in the session. You should perform this check on the controller actions where they need to be an admin. It will not affect performance to any noticeable degree and is important for the security of your site.

Also, you may want to check out the CanCanCan gem, which is a fork of CanCan built by Ryan Bates, for an example of how this works. Unless you're building the application for educational purposes, I highly recommend the CanCanCan gem.

Hope this helps!

Upvotes: 1

Related Questions