ruby on rails 4 - Rendering wrong head with login layout -
can tell me how possibile following layout in rails 4 app
# app/views/layout/login.html.erb <!doctype html> <html> <head> <meta content="text/html; charset=utf-8" http-equiv="content-type"> <title>pippo</title> <meta content="yes" name="apple-mobile-web-app-capable"> <meta content="black-translucent" name="apple-mobile-web-app-status-bar-style"> <meta name="viewport" content="initial-scale = 1.0,maximum-scale = 1.0" /> <link href="/assets/login.css" media="all" rel="stylesheet" /> <script src="/assets/login.js"></script> <%= csrf_meta_tags %> </head> <body> <div class="main-content"> <%= yield %> </div> </body> </html>
with following controller
class sessionscontroller < applicationcontroller layout 'login' ... def destroy session.find(session[:id]).close reset_session respond_to |format| flash[:success] = t('sessions.logout') format.html { redirect_to login_url } end end end
and routes
... 'login', to: 'sessions#new', as: 'login' 'logout', to: 'sessions#destroy', as: 'logout' ...
produces following html once click on <%= link_to 'logout', logout_path %>
?
<head> <meta content="text/html; charset=utf-8" http-equiv="content-type"> <title>pippo</title> <meta content="yes" name="apple-mobile-web-app-capable"> <meta content="black-translucent" name="apple-mobile-web-app-status-bar-style"> <meta name="viewport" content="initial-scale = 1.0,maximum-scale = 1.0" /> <link href="/assets/application.css" media="all" rel="stylesheet" /> <script src="/assets/application.js"></script> <meta content="authenticity_token" name="csrf-param" /> <meta content="l9+umk+wjpxy4ufikeeuqkggmvjbbz2udxyjhowtjfo=" name="csrf-token" /> </head>
am missing here? 2 days i'm trying figure out. why using head main layout instead of 1 in login?
thanks help.
update - forgot mention log file states:
rendered sessions/new.html.erb within layouts/login (1.4ms)
as per layout name given in question, i.e.,
app/views/layout.login.html.erb
there couple of things wrong here:
- layouts should placed in
app/views/layouts
folder - file name should
login.html.erb
, notlayout.login.html.erb
in case, rails not find login.html.erb
in app/views/layouts
, rendered default layout app/views/layouts/application.html.erb
.
Comments
Post a Comment