Re: ActiveRecord Validation not working

jemminger
Mon, 30 Jul 2007 22:08:03 -0000

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 Bromwell
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:
> 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.
> --
> Posted viahttp://www.ruby-forum.com/.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---