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..... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Oct 15, 8:28 am, cool <eshward...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: 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 blankIf you use the ! variants of save, create, update_attributes etc... then validation failures raise an error instead of returning false. Fred> > how can i do that in the controller and model > > badly i need a help in this its urgent and imp.....--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
then what can i use in the controller create method, can u help me regarding this plzz On Oct 15, 1:13 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Oct 15, 8:28 am, cool <eshward...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > g like > > > ate > > > > 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 > > > > > how can i do that in the controller and model > > > badly i need a help in this its urgent and imp.....--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---