read params from form ot working

params[:user] isnt the username, its a hash which contains all form parameters like username and all the other stuff from the form

try this:

username = params[:user][:username]