How to render a view from a view using a condition?
<p>I'm testing out RoR and am currently trying to figure out the functionality which allows users with a valid session to skip logging in.</p>

<p>The login button usually prompts you to a login page, whereas I want to make it so that people with a session skip it and immediately get redirected to the show view using a conditional statement. (Checks via current_user)
(If you need any other code just comment)</p>

<p>Here's the login view</p>

<pre><code>&lt;%= form_for :session, url: '/login' do |s| %&gt;
&lt;%= s.text_field :username, :placeholder =&gt; 'Username' %&gt;
&lt;%= s.password_field :password, :placeholder =&gt; 'Password' %&gt;
&lt;%= s.submit "Login" %&gt;

&lt;% if current_user %&gt;
    &lt;!-- What do i write here? --&gt;
    &lt;!-- Maybe I should put this in a controller? --&gt;
    &lt;% end %&gt;

&lt;% if flash[:notice] &amp;&amp; current_user %&gt;
    &lt;div class="notice"&gt;&lt;%= flash[:notice] %&gt;&lt;/div&gt;
&lt;% end %&gt;
</code></pre>



<p>Here's the application controller containing the current_user function. (just in case)</p>

<pre><code>class ApplicationController &lt; ActionController::Base
protect_from_forgery with: :exception

helper_method :current_user

 def current_user
   @current_user ||= User.find_by(id: session[:id]) if session[:id]
 end
end
</code></pre>