ActiveRecord Validation not working


#1

I am have trouble trying to figure out how validation is suppose to
work. here is what I have:

validates_length_of :emailOptionTwo, :within => 1…11

When I submit my form with a value the is outside the with, I do not get
an error. The render action int the control is being executed.


#2

you should get the error when you try to save, something like so:

def create
@model = MyModel.new(params[:my_model])
if @model.save
flash[:notice] = ‘Success’
redirect_to :some_action
else
flash[:error] = ‘Error’
render :action => :new
end
end

then typically in your view you’d show the errors:
<%= error_messages_for :my_model %>

On Jul 30, 4:52 pm, Ron B. removed_email_address@domain.invalid