Created
September 2, 2011 08:51
-
-
Save meleyal/1188217 to your computer and use it in GitHub Desktop.
typus admin user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
undefined local variable or method `admin_user' for Admin::StudentsController:Class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Admin::StudentsController < Admin::ResourcesController | |
p admin_user | |
end |
I thought this would return the current admin user, so I could do something like:
@student = Student.find_by_admin_user_id(admin_user.id) if admin_user.role == "student"
You can access admin
user but from an instance method.
def index
# admin_user
end
OK, makes sense.
What I actually want to do is redirect the user to their profile when they login, something like:
if admin_user.role == "student"
@student = Student.find_by_admin_user_id(admin_user.id)
redirect_to @student
end
(So they bypass the dashboard, index etc.)
Is there a better way to achieve this?
Makes sense to redirect the user like this.
But what would the redirect look like? I don't see any named routes for admin resources.
The redirect should go to e.g. admin/students/edit/1
, where 1
is the profile id of the current admin user.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What are you expecting to see there?