title: How to make popup registration using bootstrap modals in Rails?
body: <p><p>I spent a lot of time trying to make this using Devise gem, but decided to do it anoter way - writing my own controllers.
  <p>I want that, modal didn't hide if there errors in  registration or login.
  <p>I think I should render js so need to use Ajax, that I don't know. 
  <p>My simple controllers(I need edit them, there is error there):</p>
  
  <pre><code>   def new
      @user = User.new
     end
  
     def create
       @user = User.new(params[:user])
    if @user.save
      redirect_to @user
     else
    render :js =&gt; "('#sign_up').modal('show');"//or something else I don't know
     end
    end
  </code></pre>
  
  <p>And code in my application.html.erb (where should I put it in new.js.erb?):</p>
  
  <pre><code>  &lt;%= link_to  "Sign_up", '#sign_up', { 'data-toggle' =&gt; 'modal', 'data-target' =&gt; "#sign_up"}%&gt;
  
      &lt;div id="sign_up" class="modal hide fade in" style="display: none;"&gt;
     &lt;%= render :template =&gt; "users/new" %&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>I receive error:</p>
  
  <pre><code>    undefined method `model_name' for NilClass:Class
  </code></pre>
  
  <p>Extracted source (around line #5):</p>
  
  <pre><code>      3: &lt;div class="row"&gt;
        4:   &lt;div class="span6 offset3"&gt;
        5:     &lt;%= form_for(@user) do |f| %&gt;
  .....
  </code></pre>
  
  <p><b>EDITED:</b></p>
  
  <p>When I put @user in home controller(my root_path)</p>
  
  <pre><code> class StaticPagesController &lt; ApplicationController 
      def home
        @user = User.new 
      end    
   end
  </code></pre>
  
  <p>it all worked, but is it good?
  I want to stay on page, where I clicke sign up. How to do this ?</p>