views:

46

answers:

1

Hello, here is my partial for writing a comment:

<div class="commentBox">
    <%=form_for [commentable,Comment.new], :remote => true do |f|%>
        <%=f.text_area :content, :placeholder=>"Write a comment...", :title=>"Write a comment..." %>
        <%=f.hidden_field :parent_id%>
        <br />
        <%=f.submit "Add comment"%>
    <%end%>
</div>

The issue with this is that the page is loading which the following:

....<textarea title="Write a comment..." rows="20" placeholder="Write a comment..." name="comment[content]" id="comment_content" cols="40"></textarea>

The problem with this is that my page can have several items on it that are commentable. So having a TEXTAREA with ID doesn't work...

What I'd like is for the textarea to have a class of comment_content, and then in the form I can add a hidden field with the recordID where the comment can live and then in the controller use that ID to insert into the DB. Does this sound like the right idea?

Thoughts?

+2  A: 

You can always override default attributes such as id.

<%=f.text_area :content, :id => "text-1" %>
<%=f.text_area :content, :id => "text-2" %>
Nando Vieira
Based on the use case above. Do you think that's the way to go?
AnApprentice
@TheApprentice: Absolutely if you want to uniquely identify them.
Ryan Bigg