If what you want is to verify that the email is unique/valid, put
these two lines in your model.
validates_format_of :email, :with =>
/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :message => "Invalid
email"
validates_presence_of :email
If you really want to modify whatever the user passed in, you can do
something like this:
params[:user][:email] = "some@otheremail.com"
-javier godinez
What does your controller look like?
Michael M. wrote:
this is my controller.
class UserController < ApplicationController
def index
end
def new
@user = User.new(params[:user])
return unless request.post?
if @user.save
redirect_to(:action => 'index')
end
end
def edit
end
def list
end
end
it works, but when I add the line @user.name = params[:user][:email] I receive the error message.
puts params[:user].inspect
{"name"=>"abc", "email"=>"abc@def.com"}
I thing the problem is I, cannt read "email"=>"abc@def.com" with params[:user][:email]
You've got to make sure you only access params[:user][:email]
on a post, because params[:user] will be nil on a get, and
you'll get an error.
Prashanth
(Prashanth)
July 12, 2007, 10:56am
5
I think you are trying to access both the user and the email and store
in the user table right? if that is the case you can do something like
this User.new("user" => params[:user], email => params[:email]).