So I have a content_for
inside my view for logging in and in the sessions controller, I have render :new
when the user does not enter valid credentials. However, when it does render :new
, I get a black and white page without any css or js. This is how my content_for
look like
<% content_for :head do %>
<%= stylesheet_link_tag "user_sessions/new" %>
<%= javascript_include_tag 'user_sessions/new.onready' %>
<% end %>
Is there a work around to make sure that the above code gets executed when I do render
?
My guess would be that you're not including the content_for
anywhere. In app/views/layouts/application.html.erb
(or whichever layout you're using for this page) make sure you've got something like the following:
<head>
<!-- your regular head content goes here -->
<%= content_for :head %>
</head>
When you pass a block to content_for
, the contents of the block are stored to be used elsewhere. The call to content_for
without a block will then insert that stored content.
See the docs for content_for
for more info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With