Yash wrote:> 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?
>
<%= 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...
--
Alex