Create a logging system


I would like to create a loggin system. I have a players model with
name and passwd. Then, I would like to put the player item in the

When I try to loggin, it create a player, so, I'm kind of lost here :

login_controller.rb :

class LoginController < ApplicationController
  def index
    if request.get?
      @Player =
      @Player =[:player])
      logged_in_user = @Player.try_to_login
      if logged_in_user
        flash[:notice] = "Utilisateur invalide"


class Player < ActiveRecord::Base
  has_one :accessory
  has_many :possessions
  has_many :games, :through =>:possessions, :select =>
"possessions.user_notation, possessions.user_comment, games.*"

  def self.login (name, password)
    find(:first, :conditions => ["name = ? and password = ?", name,

  def try_to_loggin
    Player.login(, self.password)


index.html.erb in login

<% form_for(@Player) do |f| %>
<%= f.error_messages %>
    <%= f.text_field :name %>
    <%= f.text_field :password %>
  <%= f.submit "Login" %>
  <% end %>

Any ideas ? Link that can help ? Thanks !

Use something like restful_authentication

There's no way of doing it simply ? Because I'm kind of new in Ror,
and I'd like to work this out with only the basics.

Ok, I've finally found this
Adapting this is fine.