Note that there are some explanatory texts on larger screens.

plurals
  1. POWhere I got a NoMethodError using restful authorization?
    primarykey
    data
    text
    <p>This is the code from my login Page:</p> <pre><code>&lt;%= flash[:notice]%&gt; &lt;h1&gt;System&lt;/h1&gt; &lt;%= Time.now%&gt;&lt;/p&gt; &lt;p&gt;&lt;%=link_to "Register", signup_path%&gt;&lt;/p&gt; &lt;div id="login"&gt; &lt;%if logged_in? %&gt; &lt;b&gt;&lt;%=current_user.login%&gt;&lt;/b&gt; &lt;%=link_to "Signout", logout_path%&gt; &lt;%else%&gt; &lt;% form_remote_tag :url =&gt; session_path do -%&gt; &lt;p&gt;&lt;%= label_tag 'login' %&gt; &lt;%= text_field_tag 'login', @login %&gt; &lt;%= label_tag 'password' %&gt; &lt;%= password_field_tag 'password', nil %&gt;&lt;/p&gt; &lt;p&gt;&lt;%= label_tag 'remember_me', 'Remember me' %&gt; &lt;%= check_box_tag 'remember_me', '1', @remember_me %&gt;&lt;/p&gt; &lt;p&gt;&lt;%= submit_tag 'Log in' %&gt;&lt;/p&gt; &lt;% end -%&gt; &lt;%end%&gt; &lt;/div&gt; </code></pre> <p>And this is the sessions_controller.rb:</p> <pre><code># This controller handles the login/logout function of the site. class SessionsController &lt; ApplicationController # Be sure to include AuthenticationSystem in Application Controller instead #include AuthenticatedSystem # render new.rhtml def new end def create logout_keeping_session! user = User.authenticate(params[:login], params[:password]) if user # Protects against session fixation attacks, causes request forgery # protection if user resubmits an earlier form using back # button. Uncomment if you understand the tradeoffs. # reset_session self.current_user = user new_cookie_flag = (params[:remember_me] == "1") handle_remember_cookie! new_cookie_flag #redirect_back_or_default('/') flash[:notice] = "Logged in successfully" self.reload_login() else note_failed_signin @login = params[:login] @remember_me = params[:remember_me] render :action =&gt; 'new' end end def destroy logout_killing_session! flash[:notice] = "You have been logged out." redirect_back_or_default('/') end def reload_login respond_to {|format| format.js} flash[:notice] = "What the hell?" end protected # Track failed login attempts def note_failed_signin flash[:error] = "Couldn't log you in as '#{params[:login]}'" logger.warn "Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}" end end </code></pre> <p>I can login the page, but while I wait for a while, several minutes later, I found that I got NoMethodError in System#index error...</p> <pre><code>undefined method `remember_token?' for true:TrueClass Extracted source (around line #6): 3: &lt;%= Time.now%&gt;&lt;/p&gt; 4: &lt;p&gt;&lt;%=link_to "Register", signup_path%&gt;&lt;/p&gt; 5: &lt;div id="login"&gt; 6: &lt;%if logged_in? %&gt; 7: &lt;b&gt;&lt;%=current_user.login%&gt;&lt;/b&gt; 8: &lt;%=link_to "Signout", logout_path%&gt; 9: &lt;%else%&gt; </code></pre> <p>I don't know what's going wrong, it works in the first launch. But if I go to "<a href="http://localhost:3000/login" rel="nofollow noreferrer">http://localhost:3000/login</a>" to login again, the error is gone, what happened? thank u.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
    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