we have lots of panel in out Application like admin , teacher principal , student , parent etc .
Each panel have its own layout So upon login we handle this using WelcomeController
class WelcomeController < ApplicationController
def index
respond_to do |format|
format.html do
return render :home if current_user.nil?
return render :admin if current_user.super?
return redirect_to("/student/lesson") if current_user.student?
return redirect_to("/teacher/lesson") if current_user.teacher?
return render "layouts/principal" if current_user.principal?
return render "layouts/coordinator" if current_user.coordinator?
return render "layouts/viceprincipal" if current_user.viceprincipal?
return render "layouts/parent" if current_user.parent?
end
end
end
end
So right now for getting data from controller we redirect to his route Like for Student
return redirect_to("/student/lesson") if current_user.student?
but we wants that on URL / we get data from controller . So my problem is how to get data ? So we can use in views
I am new to Rails , if I am using something wrong Please let me know . Will I get data from Model ?
In routes we use
get '/student/lesson', to: 'student_lesson_plan#index', as: 'student_lesson'
And from index Action we have variables which we use . So I want instead of
return redirect_to("/student/lesson") if current_user.student? something like this
return render "layouts/student" if current_user.student?
And I can use those variables which I initialize in student_lesson_plan#index or from another place
Aucun commentaire:
Enregistrer un commentaire