Hello,
My validate is not working, I don’t know why, it just stopped working?
Model:
class User < ActiveRecord::Base
validates_presence_of :nickname, :email, :password
validates_confirmation_of :password
validates_length_of :nickname, :password, :within => 5…40
validates_uniqueness_of :nickname, :email
validates_format_of :email, :with =>
/^([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i
end
Controller:
def signup
if request.post?
user = User.new(params[:user])
if user.save
flash[:notice] = “Signup successful”
redirect_to :action => ‘login’
end
end
end
View:
<%= start_form_tag :action=> “signup” %>
<%= error_messages_for ‘user’ %>
- Desired nickname:
- <%= text_field "user", "nickname", :size => 20 %>
- <%= password_field “user”, “password_confirmation”, :size => 30
%>
<dt><label for="user_login">Email:</label></dt>
<dd><%= text_field "user", "email", :size => 30 %></dd>
<dt><label for="user_password">Choose password:</label></dt>
<dd><%= password_field "user", "password", :size => 30 %></dd>
<dt><label for="user_password_confirmation">Confirm
password:
<dt></dt>
<dd><input type="submit" value="Signup »" class="primary"
/>
<%= end_form_tag %>
Can anyone see anything wrong??