How to create simple login form

i m new to ROR…
i make a simple progm for login…

Username and password…

if(right)
{
login
}
else
{
error msg
}

can u help me in this…
My form is


<% form_tag :controller => “user”, :action => “login_submit” do %>

Username:  

Password:  

<%= submit_tag “Login”%>
<% end %>


looks good to me. What’s the problem?

On Mon, Apr 28, 2008 at 1:34 PM, Manish N.

Roger P. wrote:

looks good to me. What’s the problem?

On Mon, Apr 28, 2008 at 1:34 PM, Manish N.

my action is
def login_submit
if session[‘user’]
@logged_in = true
else
@logged_in = false
end
@user = User.new(params[‘user’])
if session[‘user’] = User.authenticate(params[‘user’][‘username’],
@params[‘user’][‘password’])
flash[:notice] = l(:user_login_succeeded)
redirect_to :action => ‘welcome’
else
@login = @params[‘user’][‘login’]
flash.now[:notice] = l(:user_login_failed)
end
end

ERROR IS -------
NoMethodError in UserController#login_submit

You have a nil object when you didn’t expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]

there are two lines that seem a bit strange…

@user = User.new(params[‘user’])

why create an User object during login? or do you want to make sure, a
user with this username/password does exist? in this case you would have
to save the thing.
(and make sure, the creation does not fail)

and this line:
@login = @params[‘user’][‘login’]

it should be params of course without the @. but still there is no input
field “login” in your form.