Rails Log user in after view rendered

I have an apply view (index page) where the user can leave his
credentials if he applies from that views an account will be generated
an the user will be logged in. And an overview page will be shown
(create page)

But if he is already logged in and applies the sentence "we have send
your password to … cannot be shown in my view.

So I have made the following:

  <% unless user_signed_in? %>
    <div class="row">
      <div class="three columns">
        <strong><%= t("apply.create.labels.password") %></strong>:
      <div class="nine columns">
        <%= t("apply.create.labels.emailed_password_html", :link =>

<%= link_to(t(“apply.create.labels.choose_password”),
user_profile_path) %>

<% priv_sign_in %>
<% end %>

This code is because. If the user applies the @user info is filled in
but he can only be logged in after this part of the view is generated.

In my applycontroller create I have the following to do priv_sign_in:

 # Helpers
  helper_method :priv_sign_in

  # Sign in User from View
  def priv_sign_in

Is there any better way to do is. So in an effort to make things more

When I enter the create view this has to be done:

If the user is logged in --> Hide part of view
If the user is not logged in --> Show part of view and try to log in

If it is not clear please ask some questions, thanks a lot! :slight_smile: