Note that there are some explanatory texts on larger screens.

plurals
  1. PONameError in Sessions#new
    primarykey
    data
    text
    <p>I'm getting <a href="http://i.imgur.com/xmf7q.png" rel="nofollow">this error</a>: <code>undefined local variable or method</code>sessions_path' for #&lt;#:0x2db44c8><code>when I go to</code>localhost:3000/login` which isn't making much sense to me seeing the code is exactly like that of a previous application where it does work.</p> <p>Here are the code of the related files.</p> <p><br> <strong>routes.rb</strong></p> <pre><code>get 'register' =&gt; 'users#new', :as =&gt; 'register' get 'login' =&gt; 'sessions#new', :as =&gt; 'login' get 'logout' =&gt; 'sessions#destroy', :as =&gt; 'logout' resources :users, :path =&gt; '/' root :to =&gt; 'users#index' match '/:id' =&gt; 'users#show' </code></pre> <p><br> <strong>sessions_controller.rb</strong></p> <pre><code>class SessionsController &lt; ApplicationController def new end def create user = User.find_by_email(params[:email]) if user &amp;&amp; user.authenticate(params[:password]) session[:user_id] = user.id redirect_to root_url, :notice =&gt; 'Logged in!' else flash.now.alert = 'Invalid email or password' render 'new' end end def destroy session[:user_id] = nil redirect_to root_url, :notice =&gt; 'Logged out!' end end </code></pre> <p><br> <strong>views/sessions/new.html.erb</strong></p> <pre><code>&lt;h1&gt;Log in&lt;/h1&gt; &lt;%= form_tag sessions_path do %&gt; &lt;div class="field"&gt;&lt;/div&gt; &lt;%= label_tag :email %&gt; &lt;%= text_field_tag :email, params[:email] %&gt; &lt;/div&gt; &lt;div class="field"&gt;&lt;/div&gt; &lt;%= label_tag :password %&gt; &lt;%= text_field_tag :password %&gt; &lt;/div&gt; &lt;div class="actions"&gt;&lt;%= submit_tag "Log in"%&gt;&lt;/div&gt; &lt;% end %&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload