Adding a diary watchlist

Josh Doe josh at joshdoe.com
Sun Sep 11 21:08:04 BST 2011


I (and I'm sure others) have mentioned this before, but I think adding
a diary watchlist, or letting users subscribe to diary updates (edited
post and new comments) would be quite useful. I've never done anything
with rails, so I'd like to know how others think it should be
implemented.

MediaWiki uses the following table:
CREATE TABLE watchlist (
  wl_user int unsigned NOT NULL,
  wl_namespace int NOT NULL default 0,
  wl_title varchar(255) binary NOT NULL default '',
  -- Timestamp when user was last sent a notification e-mail;
  -- cleared when the user visits the page.
  wl_notificationtimestamp varbinary(14)
)

This suggests:
CREATE TABLE diary_watchlist (
    id INTEGER NOT NULL, -- autoincrement primary key
    user_id BIGINT NOT NULL, -- references users(id)
    diary_entry_id BIGINT NOT NULL, -- references diary_entries(id)
    notificationtimestamp TIMESTAMP WITHOUT TIME zone
);

I don't know the first thing about Rails, but I'm guessing I'd then
have to modify at least app/views/diary_entry/view.html.erb to add a
"Add to watchlist" link/button, and add a watch method to
app/controllers/diary_entry_controller.rb, as well as modify comment
and edit to trigger the sending of notifications, and then in
app/models/notifier.rb add a diary_update_notification method.

I'm sure I'm missing other bits, but I think before I go any further I
need to learn the basics of Ruby and Rails, as well as get feedback
from others. Of course, if anyone else wants to implement this ahead
of me please do so; I just want to get the functionality in there!

-Josh



More information about the rails-dev mailing list