In my app I have a article and comment model. I implemented a reply-feature, so that a user can reply to another comment by simply putting the id of the comment they want to quote in the comment form like this: #26 (to quote comment with id 26). This all works fine, with the regex and reply to user_id attr:
extract from my comments_controller create action:
if @comment.content.match(/(#([1-9]+))\s/)
iteration_fragment = $2
iteration_id = %Q{#{ iteration_fragment }}
if @replied_to_comment = @article.comments.where(:iteration_id => iteration_id).first
@comment.in_reply_to_user_id = @replied_to_comment.user_id
end
end
Now, without creating a new model, I just want to put a ‘html helper layer’ on top of my comment system, so that these fragments such as “#33” automatically are converted to a “#33” onmouseover link, showing the content of comment 33 onmouseover. So I don’t want bb code quoting, but rather be really minimalist.
Does anybody know, what I’m looking for and how it should be approached?
The word automatic makes me think that the only way you could do this is with jQuery..
That’s the automatic part..
To make the page load with the content in Rails, it would be something like :
In your comment model
Then you apply it liberally with :