# Adding comments

**URL:** <https://www.ruby-forum.com/t/adding-comments/98208>\
**Category:** Radiant CMS\
**Created:** [July 13, 2006, 3:02am UTC](https://www.ruby-forum.com/t/adding-comments/98208 "2006-07-13T03:02:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![al-evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@al-evans](https://www.ruby-forum.com/u/al-evans)\
**Post date:** [July 13, 2006, 3:02am UTC](https://www.ruby-forum.com/t/adding-comments/98208/1 "2006-07-13T03:02:57Z")

</div>

I have a hacked together version of Radiant with the capability of  
allowing users to add comments. It’s somewhere between “demo” and  
“pre-alpha” quality at the moment. I’ll make the code available (as an  
svn diff against HEAD) in the next few days to anybody who’s interested.

Here’s a brain dump of the things I ran into, and my resolutions. I  
don’t pretend these are the best solutions, but they’re the ones I got  
working first:-)

I gave up the idea of using a comment behavior. I kept running into the  
problem that behaviors are conceptually exclusive, as opposed to nesting  
or stacking.

Instead, I added a “commentary” page part to each page for which I  
wanted to allow comments. This “commentary” part contains only an AJAX  
request link to “Add Comment”. Issue: there might have been some way I  
could have used the Rails “link\_to\_remote” helper, but I couldn’t figure  
it out. I just wrote the literal link.

Since I wanted to use OpenID instead of the real login system just to  
authenticate comments, I added a “commentaries” table, model, and  
controller to the system. So far, I’ve not been successful at making  
them look like they belong there:-)

So the AJAX request causes the link to be replaced by a text field and  
button for OpenID login. On success (the actual authentication is  
stubbed in pending some experiments with AJAX and OpenID), this is  
replaced by fields for name, email, and comment. When the user clicks  
the submit button on this, it all goes back to the original state with  
just the “Add Comment” link, which is now below the new comment. This  
all works fine.

The solution to rendering the comments, though, is a complete hack. I  
added a render\_page\_commentaries method to behavior.rb that just creates  
an ERB template, feeds the page’s commentaries through it, and splurts  
out the result. The radius code in page\_context.rb  
calls this if part\_name =~ /commentary/. This is obviously not an ideal  
solution, but it was a lot quicker than figuring out how to do it in  
Radius:-)

My main conceptual problem in working on this is the lack of model/view  
separation when the view IS the model.

So there you go, for what it’s worth. First, get something working:-)  
Let me know if you’d like a copy of it when I get it cleaned up a  
little.

–Al Evans

---

<div class="post-metadata">

**Author:** ![al-evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@al-evans](https://www.ruby-forum.com/u/al-evans)\
**Post date:** [July 13, 2006, 4:16pm UTC](https://www.ruby-forum.com/t/adding-comments/98208/2 "2006-07-13T16:16:24Z")

</div>

Al Evans wrote:

> I have a hacked together version of Radiant with the capability of  
> allowing users to add comments. It’s somewhere between “demo” and  
> “pre-alpha” quality at the moment. I’ll make the code available (as an  
> svn diff against HEAD) in the next few days to anybody who’s interested.

Any chance we could see a live demo somewhere along with the diff?

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![al-evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@al-evans](https://www.ruby-forum.com/u/al-evans)\
**Post date:** [July 13, 2006, 4:25pm UTC](https://www.ruby-forum.com/t/adding-comments/98208/3 "2006-07-13T16:25:25Z")

</div>

John W. Long wrote:

> Any chance we could see a live demo somewhere along with the diff?

After I’m a little happier with it, and especially after I have the  
async OpenID authentication working, yes. I’ll put it up and post an  
announcement.

–Al Evans
