First, thanks for reading this post!
Today i’m trying to implement a real-time form validator.
I have a model (user) within:
t.column :email, :string
t.column :name, :string
t.column :surname, :string
t.column :nickname, :string
t.column :gender, :integer
t.column :site, :string
t.column :birthday, :datetime
t.column :culinary, :string
t.column :avatar, :string
t.column :description, :string
t.column :password, :string
t.column :active, :boolean, :default => false
the validation rules:
validates_uniqueness_of :email, :nickname
validates_length_of :password, :within => 4…10
validates_length_of :email, :maximum => 50
validates_presence_of :name, :surname, :email, :password, :nickname
validates_format_of :email,
:with =>
/^([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i # ( needs a improve )
and the controller code:
def signup
@title = “site_name: signup”
unless logged_in?
@user = User.new(params[:user])
if @user.valid? #@user.save
flash[:notice] = “user registered”
end
else
redirect_to :controller => “site_name”, :action => “index”
end
end
And i wan’t to use XML (RJS), to validate in real-time what the user
type in
fields. If what was type can’t be allowed (see validate rules) a message
or
a red border indicates a error. I try several times, read a lot of
articles
in google and see 4 railscasts.
Can anyone help me?
Obs.: sorry for my poor english.
–
Regards,
Luiz Vitor Martinez C.
cel.: (11) 8187-8662
blog: rubz.org
engineer student at maua.br