active record validations by Eshwar

hi

here is my form fields

          <tr>                 <td><%= text_field :title, :name => 'external_link[title]' %></td>                 <td><%= text_field :url, :name => 'external_link[url] ' %></td>       </tr>       <tr>                 <td><%= link_to_function 'Add', "add();" %></td>

if i click add link there will be added 2 more text fields as above

in the controller iam using like

def create     puts params[:external_link][:title].inspect       params[:external_link][:title].each_with_index do |l, i|   ExternalLink.create!({:title => l, :url => params[:external_link] [:url][i], :label => params[:label]})       end       redirect url(:external_links)   end

in the model i have specified as

validates_presence_of :title, :url

the problem is when i submit the the form with out entering any details its not checking validation its giving error like

Validation failed: Title can't be blank, Url can't be blank

how can i do that in the controller and model

badly i need a help in this its urgent and imp.....

g like

def create puts params[:external_link][:title].inspect params[:external_link][:title].each_with_index do |l, i| ExternalLink.create!({:title => l, :url => params[:external_link] [:url][i], :label => params[:label]}) end redirect url(:external_links) end

in the model i have specified as

validates_presence_of :title, :url

the problem is when i submit the the form with out entering any details its not checking validation its giving error like

Validation failed: Title can't be blank, Url can't be blank

If you use the ! variants of save, create, update_attributes etc... then validation failures raise an error instead of returning false.

Fred

then what can i use in the controller create method, can u help me regarding this plzz