# Active record validations by Eshwar

**URL:** <https://www.ruby-forum.com/t/active-record-validations-by-eshwar/150958>\
**Category:** Rails\
**Created:** [October 15, 2008, 9:28am UTC](https://www.ruby-forum.com/t/active-record-validations-by-eshwar/150958 "2008-10-15T09:28:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cool](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c6cbf5/32.png) [@cool](https://www.ruby-forum.com/u/cool)\
**Post date:** [October 15, 2008, 9:28am UTC](https://www.ruby-forum.com/t/active-record-validations-by-eshwar/150958/1 "2008-10-15T09:28:37Z")

</div>

hi

here is my form fields

```
      <tr>
            <td><%= text_field :title, :name =>

```

‘external\_link[title][]’ %\>

\<%= text\_field :url, :name =\> ‘external\_link[url]  
[]’ %\>  
  
  
\<%= link\_to\_function ‘Add’, “add();” %\>

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…

---

<div class="post-metadata">

**Author:** ![cool](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c6cbf5/32.png) [@cool](https://www.ruby-forum.com/u/cool)\
**Post date:** [October 15, 2008, 10:13am UTC](https://www.ruby-forum.com/t/active-record-validations-by-eshwar/150958/2 "2008-10-15T10:13:48Z")

</div>

On Oct 15, 8:28 am, cool [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:  
g like

> 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

---

<div class="post-metadata">

**Author:** ![cool](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c6cbf5/32.png) [@cool](https://www.ruby-forum.com/u/cool)\
**Post date:** [October 15, 2008, 10:58am UTC](https://www.ruby-forum.com/t/active-record-validations-by-eshwar/150958/3 "2008-10-15T10:58:25Z")

</div>

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

On Oct 15, 1:13 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
