title: create a count method for user logins with ruby on rails
body: <p>what I want: A user logs in to his account he and automatically updates his own counter (@counter += 1).</p>
  
  <p>I am new to Ruby and Rails and I am using Rails 3.2.12. I read the book "eloquent ruby", searched stackoverflow regarding this question and watched a video-ruby-course from pragmaticstudio.com. In that video-course they created a Class like this:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    attr_accessible :name, :email, :password, :password_confirmation, :counter
    has_secure_password
    before_save { |user| user.email = email.downcase }
    before_save :create_remember_token
  
    def initialize(counter=0)
      @counter = counter
    end
  
    def w00t
      @counter += 15
    end
  
    private
      def create_remember_token
         self.remember_token = SecureRandom.urlsafe_base64
      end
  end 
  </code></pre>
  
  <p>Now in my App the User log-in is settled with a SessionsController and here come my problems because every method from the User model is "unknown" to the SessionsController.</p>
  
  <pre><code>class SessionsController &lt; ApplicationController
    def new
    end
  
    def create
      user = User.find_by_email(params[:session][:email].downcase)
      if user &amp;&amp; user.authenticate(params[:session][:password])
        sign_in user
        redirect_back_or templates_path
      else
        flash.now[:error] = 'something went wrong.'
        render 'new'
      end
    end
  
    def destroy
      sign_out
      redirect_to root_url
    end
  end
  </code></pre>
  
  <p>Here is what I already tried but didn't work for my solution: i added</p>
  
  <pre><code>user.w00t
  </code></pre>
  
  <p>in the SessionsController, 1 line above</p>
  
  <pre><code>sign_in user
  </code></pre>
  
  <p>the returned error was: "undefined methode 'w00t' for SessionsController".</p>
  
  <p>I also tried to write a method in the Sessions Helper:</p>
  
  <pre><code>def woot(template)
    template.counter += 1    
  end
  </code></pre>
  
  <p>then I re-ordered my SessionsController 'create' method like so:</p>
  
  <pre><code>def create
      template = Template.find_by_bosskey(params[:bession][:bosskey])
      if template
        woot template                  #that is my new line !
        tsign_in template
        redirect_back_or template
      else
        flash.now[:error] = 'something went wrong.'
        render 'new'
      end
    end
  </code></pre>
  
  <p>With this i did not get any errors BUT still the counter doesnt change. I am more confused then ever. Please tell me WHERE to put that method or how to fix this problem for my app I am lost.</p>