title: How to use devise in an other model?
body: <p>I'm trying to implement devise login into a nav, but I'm facing to an error that I can't solve. When i'm submit my form to run the connection, I have this error :</p>
  
  <pre><code>No route matches [POST] "/login"
  </code></pre>
  
  <p>So I followed this <a href="https://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-app" rel="nofollow noreferrer">wiki/devise</a> which deals with the subject. But is not working with the line :</p>
  
  <pre><code>helper_method :resource_name, :resource, :devise_mapping
  </code></pre>
  
  <p>I have this error :</p>
  
  <blockquote>
    <p>undefined method `helper_method' for PlainpageHelper:Module</p>
  </blockquote>
  
  <p>For my last attempt, i'd try to add this lines into my routes file, but it's still not working </p>
  
  <pre><code>get 'login', to: 'sessions#new', as: 'login'
  get 'logout', to: 'sessions#destroy', as: 'logout'
  get 'signup', to: 'users#new', as: 'signup'
  </code></pre>
  
  <p>My code :</p>
  
  <p>My app (views/layout/application) =</p>
  
  <pre><code>  &lt;%- if user_signed_in? %&gt;
      &lt;%= render 'partial/_connected'%&gt;
    &lt;% else %&gt;
      &lt;%= render 'partial/_disconnected'%&gt;
    &lt;% end %&gt;
  </code></pre>
  
  <p>My form (views/partial/_disconnected) =</p>
  
  <pre><code>&lt;li&gt;
     &lt;div class="row"&gt;
        &lt;div class="col-md-12"&gt;
          Connection via
          &lt;div class="social-buttons"&gt;
            &lt;a href="#" class="btn btn-fb"&gt;&lt;i class="fa fa-facebook"&gt;&lt;/i&gt; Facebook&lt;/a&gt;
            &lt;a href="#" class="btn btn-tw"&gt;&lt;i class="fa fa-twitter"&gt;&lt;/i&gt; Twitter&lt;/a&gt;
          &lt;/div&gt;
  
           &lt;form class="form" role="form" method="post" action="login" accept-charset="UTF-8" id="login-nav"&gt;
              &lt;%= simple_form_for(resource, url: session_path(resource_name)) do |f| %&gt;
  
                &lt;div class="form-group"&gt;
                  &lt;%= f.input :email, required: false, autofocus: true %&gt;
                &lt;/div&gt;
                &lt;div class="form-group"&gt;
                  &lt;%= f.input :password, required: false %&gt;
                &lt;/div&gt;         
  
                &lt;div class="form-group"&gt;
                  &lt;%= f.submit "Connection", class: "btn btn-success" %&gt;
                &lt;/div&gt;
                &lt;div class="checkbox"&gt;
                  &lt;%= f.input :remember_me, as: :boolean if devise_mapping.rememberable? %&gt;
                &lt;/div&gt;
              &lt;% end %&gt;
           &lt;/form&gt;
        &lt;/div&gt;
        &lt;div class="bottom text-center"&gt;
          New here ? &lt;a href="#"&gt;&lt;b&gt;Join Us&lt;/b&gt;&lt;/a&gt;
        &lt;/div&gt;
     &lt;/div&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>The plain page helper :</p>
  
  <pre><code>module PlainpageHelper
  
    def resource_name
      :user
    end
  
    def resource
      @resource ||= User.new
    end
  
    def devise_mapping
      @devise_mapping ||= Devise.mappings[:user]
    end
  
  end
  </code></pre>
  
  <p>And finally my routes :</p>
  
  <pre><code>devise_for :users
  
    get 'plainpage/index'
  
    authenticated :user do
      root to: "plainpage#home", as: :authenticated_root
    end
  
    unauthenticated do
      root 'plainpage#index'
    end
  </code></pre>
  
  <p>So if you have any idea to solve this error, you'll be my hero !!
  Thanks all, and good continuation !!</p>