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
>
>
> On Mon, Aug 24, 2009 at 3:34 PM, Wap Addon <
> [email protected]> wrote:
>
>>
>> index.html.erb
>> -------------------
>> <div id="pravin">
>> <%= link_to_remote('New', :update => 'pravin',:url => {:action =>
>> :new})%>
>> </div>
>> ----------------------
>> new.html.erb
>> ----------------------
>> <div>
>> <h1>New animal</h1>
>> <% form_for @animal do |f|%>
>> <p>
>> <p>Name</p>
>> <%= f.text_field :name%>
>> </p>
>> <p>
>> <p>Desc</p>
>> <%= f.text_field :desc %>
>> </p>
>> <p>
>> <%= submit_tag 'Create' %>
>> </p>
>> <% end %>
>> <%= image_tag 'rails.PNG', 'rails.png', :size => '70x70'%>
>> <%= link_to 'Back', animals_path %>
>> </div>
>> ----------------------
>> it is my contrller
>> --------------------
>> def create
>> @animal = Animal.new(params[:animal])
>> respond_to do |format|
>> 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
>> ----------------
>> model vaidation
>> ----------------
>> class Animal < ActiveRecord::Base
>> validates_presence_of :name,:desc
>> end
>> ------------------------
>> i want to show validation on same page whenever refresh page go to on
>> main page
>> --
>> Posted via http://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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---