How to a create a main admin page

I have multiple sections of my site that need to be accessed through an
admin section. I was able to get them to work by using admin/subfolder,
but I would like to make a “dashboard” sort of page when going to just
domain.com/admin. I’d like it to include a login form and once logged in
show a list of all the controllers in the admin/ directory.

I’ve searched through many different SVNs from RailsDay and have seen
many sites that have their admin controllers in an admin/ folder, but
none seem to have a default admin page that has links to each one.

Can someone please give me some help or point me in the right direction?

On Oct 7, 2006, at 2:54 PM, John S. wrote:

many sites that have their admin controllers in an admin/ folder, but
none seem to have a default admin page that has links to each one.

Can someone please give me some help or point me in the right
direction?

You could set up an admin/welcome or admin/dashboard controller and
then map to that with a custom route such as:

map.dashboard ‘admin’, :controller => ‘admin/dashboard’

James.

James S. wrote:

map.dashboard ‘admin’, :controller => ‘admin/dashboard’

James.

I’ve done done my controllers in a RESTful way (with admin only access
to the new/edit/create/update/destroy actions) and then had an admin
controller whose index action is just what you’re describing – a
dashboard type thing showing latest activity and giving various admin
options (which link to the RESTful controllers).
HTH
CT

James S. wrote:

On Oct 7, 2006, at 2:54 PM, John S. wrote:

many sites that have their admin controllers in an admin/ folder, but
none seem to have a default admin page that has links to each one.

Can someone please give me some help or point me in the right
direction?

You could set up an admin/welcome or admin/dashboard controller and
then map to that with a custom route such as:

map.dashboard ‘admin’, :controller => ‘admin/dashboard’

James.

THANKS! I got it working.

Can you or someone please point me into the direction or give me some
tips on how to make it so a form will come up anytime someone goes to a
page such as admin/ or admin/subfolder like so?

Login: textbox
Password: textbox
Submit

On Oct 7, 2006, at 4:39 PM, John S. wrote:

then map to that with a custom route such as:
page such as admin/ or admin/subfolder like so?
You’ll want to make use of a before_filter in your controllers (or in
a class that your controllers all inherit from):

http://api.rubyonrails.org/classes/ActionController/Filters/
ClassMethods.html#M000152

You might also want to look into one of the authentication plugins,
such as acts_as_authenticated and see how that is used:

http://technoweenie.stikipad.com/plugins/show/Acts+as+Authenticated

James.


James S.

John S. wrote:

Thanks, I ran the three commands for Acts as Authenticated then put
before_filter :login_required at the top of my controllers in the admin/
folder but I’m getting “undefined method `login_required’ for
#Admin::ScheduleController:0x282a5d0”. I read through the site you
linked me to but I don’t see anything that I missed. What do I need to
do to define login_required?


Posted via http://www.ruby-forum.com/.

Hi John,

in your new account controller you should see this at the top:

Be sure to include AuthenticationSystem in Application Controller

instead
include AuthenticatedSystem

If you haven’t done this already then just comment out “include
AuthenticatedSystem” in your account controller and add it to your
application controller.

Thanks, I ran the three commands for Acts as Authenticated then put
before_filter :login_required at the top of my controllers in the admin/
folder but I’m getting “undefined method `login_required’ for
#Admin::ScheduleController:0x282a5d0”. I read through the site you
linked me to but I don’t see anything that I missed. What do I need to
do to define login_required?

On 10/7/06, John S. [email protected] wrote:

Thanks, I got the form to appear, but where how do I set up the
login/password. When I click the login button it comes up with:

Mysql::Error: Table ‘gd_development.users’ doesn’t exist: SHOW FIELDS
FROM users

I looked through many of the links on
http://technoweenie.stikipad.com/plugins/show/Acts+as+Authenticated but
couldn’t find anything about how to set up the users table??

rake db:migrate

Thanks, I got the form to appear, but where how do I set up the
login/password. When I click the login button it comes up with:

Mysql::Error: Table ‘gd_development.users’ doesn’t exist: SHOW FIELDS
FROM users

I looked through many of the links on
http://technoweenie.stikipad.com/plugins/show/Acts+as+Authenticated but
couldn’t find anything about how to set up the users table??

On Oct 7, 2006, at 10:25 PM, John S. wrote:

Thanks, I got the form to appear, but where how do I set up the
login/password. When I click the login button it comes up with:

Mysql::Error: Table ‘gd_development.users’ doesn’t exist: SHOW FIELDS
FROM users

I looked through many of the links on
http://technoweenie.stikipad.com/plugins/show/Acts+as+Authenticated
but
couldn’t find anything about how to set up the users table??

From: http://technoweenie.stikipad.com/plugins/show/User+Authentication

"The way the plugin works is simple. The first thing you do is create
the models and migration:

script/generate authenticated user account

(In older versions of the plugin, you needed to create the migration
separately:

script/generate authenticated_migration

This should no longer be necessary.)

This will not only create your User model, but an Account controller,
some unit and functional1 tests, and some libraries in lib/. Once
thatâ??s done, you can move the include AuthenticatedSystem from app/
controllers/account_controller.rb to app/controllers/application.rb.
This makes all the authentication methods available to all controllers."

so if you’ve run the generator to create your models, there should
also now be migrations in db/migrate to create the required tables.

James.


James S. : Web D.
Work : http://jystewart.net
Play : http://james.anthropiccollective.org

Thanks a lot to both of you for helping me!