Ruby On Rails different views for same action (Based on User's role) -
i have ruby on rails controller display different form logged out user logged in user.
what best way approach this? (is below way ok?)
class userscontroller < applicationcontroller def index if logged_in && is_admin render 'admin_index' end #use default index end end
sure thats fine except might 'cannot render action twice' type error (if im admin , logged in still try render default after rendering admin action)
class userscontroller < applicationcontroller def index if logged_in && is_admin render 'admin_index' else render end end end
might better
Comments
Post a Comment