# How to pre-populate Edit form in rails?

**URL:** <https://www.ruby-forum.com/t/how-to-pre-populate-edit-form-in-rails/73187>\
**Category:** Rails\
**Created:** [February 25, 2006, 12:18pm UTC](https://www.ruby-forum.com/t/how-to-pre-populate-edit-form-in-rails/73187 "2006-02-25T12:18:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/f17d59/32.png) [@yash](https://www.ruby-forum.com/u/yash)\
**Post date:** [February 25, 2006, 12:18pm UTC](https://www.ruby-forum.com/t/how-to-pre-populate-edit-form-in-rails/73187/1 "2006-02-25T12:18:57Z")

</div>

In our rails application, there is a model called Essay and another  
called Tag. Essay ‘has\_and\_belongs\_to\_many’ tags. When a user CREATEs an  
essay, he gives the text in a text field which corresponds to a database  
column in the essays table. The \_form.rhtml also provides a text area  
that lets the user tag the essay with keywords. The text area does not  
correspond directly to any single column in the essays table. The text  
is parsed and used to populate the tags table and set relations between  
the essay and the tags.

This works when I create a new essay. When I try to EDIT and essay, I  
would like to see the previously entered tags. This means the Tags text  
area should be pre-populated. How do I do this?

Thanks,  
Yash

---

<div class="post-metadata">

**Author:** ![yash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/f17d59/32.png) [@yash](https://www.ruby-forum.com/u/yash)\
**Post date:** [February 25, 2006, 1:33pm UTC](https://www.ruby-forum.com/t/how-to-pre-populate-edit-form-in-rails/73187/2 "2006-02-25T13:33:54Z")

</div>

Yash wrote:

> would like to see the previously entered tags. This means the Tags text  
> area should be pre-populated. How do I do this?

\<%= text\_field\_tag ‘essay\_tags’,  
@essay.tags.collect{|t| t.name}.join(’,’) %\>

That’s assuming that you’re splitting your tags on commas, of course…
