model validation

hello guys

i am using model validation with ajax

i have new.html.erb

it is call through link__to_remote()

then press create if any validate require page will redirect to it actual controller for ex. admins/new something like this

i want display validation message on same page in this command url can not change in all page url remain same, if any one having idea about it please share with me.

Wap Addon wrote:

hello guys

i am using model validation with ajax

i have new.html.erb

it is call through link__to_remote()

then press create if any validate require page will redirect to it actual controller for ex. admins/new something like this

i want display validation message on same page in this command url can not change in all page url remain same, if any one having idea about it please share with me.

Can you show me your code.

method in controller + html view all code.

index.html.erb

def create @animal = Animal.new(params[:animal]) respond_to do |format| #INCLUDE THIS LINE

  if @animal.save
    flash[:notice] = 'Animal was successfully created.'
    format.html { redirect_to(@animal) }
    format.xml  { render :xml => @animal, :status => :created,

:location => @animal } else format.html { render :action => “new” } format.xml { render :xml => @animal.errors, :status => :unprocessable_entity } end end end

Maheshror

def create

@animal = Animal.new(params[:animal])

respond_to do |format|

#INCLUDE THIS LINE if @animal.valid?

  #if @animal.save

animal.save

flash[:notice] = ‘Animal was successfully created.’

    format.html { redirect_to(@animal) }

    format.xml  { render :xml => @animal, :status => :created,

:location => @animal }

  else

    format.html { render :action => "new" }

    format.xml  { render :xml => @animal.errors, :status =>

:unprocessable_entity }

  end

end

end

try this

mahesh s wrote:

Maheshror

def create

   @animal = Animal.new(params[:animal])    respond_to do |format| #INCLUDE THIS LINE     if @animal.valid?      #if @animal.save

animal.save

end

try this

ok dear but it can not save record on table this is new problem. i think u tell me like this ?