Commenting


#1

Hey Bruce,

First off, I am new to Ruby, Rails, and Radiant (bout 2 months of
studying
now) but they are totally mind-blowing heh (So correct me where I say
totally wrong things). Next, I actually just started work on adding
commenting abilities to Radiant. My thoughts are a behavior is not the
best
way to go because one will potentially want to add the ability to
comment on
a page that already has a behavior (I am guessing in most cases the
behavior
will be some sort of blog behavior). My next thoughts were to implement
the
extension as a Rails plugin. However, I am having a lot of trouble
finding
information on the best way to extend a model via a plugin (lots of
people
run into issues where thier enhancements get dropped when the model gets
reloaded in a dev environment) and it also seems like testing models in
plugins is a big pain (like I said I’m a noob so the two afformentioned
things might just be necessary hurdles). In an effort to just get
something
working I went ahead and added a bunch of stuff right into Radiant,
figuring
I could pull it out into a plugin later if I solved the above problems.
I
added a Remark class to the model (I tried to create a comment model but
the
generator yeleld at me and said “comment” is a reserved rails word so
remark
== comment from here on out) that belongs_to page. I added has_many
remarks
to the Page model. I added the following tags right into page_context
(that’s right I held no reservations about mucking up the innards of
Radiant
heh): remark, remark:each, remark:author, remark:content, remark:form
remark:form is interesting as it generates a form for creating a new
comment…In order for this to work I had to modify the process method
in
Behavior with something like:
if request.post? etc etc else the normal process. This is bad because
any
behavior that processes a form and uses if request.post? to check for
form
submission will break (i.e. the mailer behavior Matt Mccray posted on
this
list). All in all I just kinda dove in…but hopefully I exposed some
potential problems re: comments. Thoughts? I’d appriciate any
direction/help/abuse :stuck_out_tongue:

Thanks!
Justin