ruby - Rails 4 does not render my Layout -
i mindblown regarding layouts in rails 4, of now, created layout controller , being called in controller using layout "layout_name"
but problem is, whenever redirect_to controller renders page not layout on top of it.
here snipper of code:
class logincontroller < applicationcontroller   layout "login_layout"   def index     user = user.new   end    def login_user     validate_credential = user.login(params[:user])     if validate_credential[0] == true       session[:user_firstname] = validate_credential[1][0]["firstname"].capitalize       session[:user_lastname] = validate_credential[1][0]["lastname"].capitalize       session[:user_id] = validate_credential[1][0]["id"]       session[:advisory_class] = validate_credential[1][0]["advisory_class"].capitalize       redirect_to :controller=> 'dashboard', :action=> 'home'     else       redirect_to :action=>'index'     end   end take not redirect_to in login_user function render layout.
and code of logout (from controller)
class dashboardcontroller < applicationcontroller   layout 'dashboard_layout'   def home   end    def settings   end    def students   end    def logout     session.clear     redirect_to :controller=>'login',:action=>'index'   end it renders page layout controller not included.
i've searched many solution still, no hopes.
this pic of how root_path looks when being called (redirect_to) dashboard controller.
and must design of root_path. (layout included). take note url same layout not being rendered. when refresh page shows layout.
i found prick, turbolinks. removed turbolinks in application.js , gem file , worked charm. layout not change because css of particular layout being called not changing. when app redirects login controller css must login.self?etc.etc. stays dashboard's css.


Comments
Post a Comment