# About HAsh in ruby

**URL:** <https://www.ruby-forum.com/t/about-hash-in-ruby/162842>\
**Category:** Rails\
**Created:** [March 14, 2009, 1:43pm UTC](https://www.ruby-forum.com/t/about-hash-in-ruby/162842 "2009-03-14T13:43:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nilez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@nilez](https://www.ruby-forum.com/u/nilez)\
**Post date:** [March 14, 2009, 1:43pm UTC](https://www.ruby-forum.com/t/about-hash-in-ruby/162842/1 "2009-03-14T13:43:33Z")

</div>

HI ALL,

I want to add values present in hash text\_fields on form after form is  
displayed. is it possible, how can i do it.

---

<div class="post-metadata">

**Author:** ![nilez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@nilez](https://www.ruby-forum.com/u/nilez)\
**Post date:** [March 14, 2009, 5:44pm UTC](https://www.ruby-forum.com/t/about-hash-in-ruby/162842/2 "2009-03-14T17:44:36Z")

</div>

HI Nilesh

Your Question is not clear,

Can you explain with some example

On Sat, Mar 14, 2009 at 6:13 PM, Nilesh K. \<

---

<div class="post-metadata">

**Author:** ![nilez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@nilez](https://www.ruby-forum.com/u/nilez)\
**Post date:** [March 16, 2009, 6:01am UTC](https://www.ruby-forum.com/t/about-hash-in-ruby/162842/3 "2009-03-16T06:01:09Z")

</div>

senthil raja wrote:

> HI Nilesh
> 
> Your Question is not clear,
> 
> Can you explain with some example
> 
> On Sat, Mar 14, 2009 at 6:13 PM, Nilesh K. \<

ok

I am fetching value from database and displaying it in text\_area  
,consider book table.I have three fields in database year,author and  
title , 2008,james,me and you is displayed in text\_area. now i have hash  
which contains different values year,author and title say 2007,john and  
happy days. I want to replace values of  
year,author and title from text\_area with values in hash. how can i do  
that?

year 2008  
author james  
title me and you

---

<div class="post-metadata">

**Author:** ![nilez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@nilez](https://www.ruby-forum.com/u/nilez)\
**Post date:** [March 14, 2009, 6:44pm UTC](https://www.ruby-forum.com/t/about-hash-in-ruby/162842/4 "2009-03-14T18:44:31Z")

</div>

for this text\_area:  
\<%= text\_area( “user”, “tasks”, :cols=\>30, :rows=\>10) %\>

default value would be to set  
@user.tasks = text\_fields[:user\_tasks]  
in your controller.

hope this is what you were looking for.

---

<div class="post-metadata">

**Author:** ![nilez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@nilez](https://www.ruby-forum.com/u/nilez)\
**Post date:** [March 16, 2009, 7:50am UTC](https://www.ruby-forum.com/t/about-hash-in-ruby/162842/5 "2009-03-16T07:50:11Z")

</div>

well, you can do that like i posted before.  
only thing you have to add is maybe an ajax-call to reload that  
textarea.  
once you figured how to put default values into that text-area, and  
how to replace\_html with ajax, this should be no problem. try it.
