Skip to content

Instantly share code, notes, and snippets.

@meleyal
Created September 2, 2011 08:51
Show Gist options
  • Save meleyal/1188217 to your computer and use it in GitHub Desktop.
Save meleyal/1188217 to your computer and use it in GitHub Desktop.
typus admin user
undefined local variable or method `admin_user' for Admin::StudentsController:Class
class Admin::StudentsController < Admin::ResourcesController
p admin_user
end
@fesplugas
Copy link

What are you expecting to see there?

@meleyal
Copy link
Author

meleyal commented Sep 2, 2011

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"

@fesplugas
Copy link

You can access admin user but from an instance method.

def index
  # admin_user
end

@meleyal
Copy link
Author

meleyal commented Sep 2, 2011

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?

@fesplugas
Copy link

Makes sense to redirect the user like this.

@meleyal
Copy link
Author

meleyal commented Sep 2, 2011

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