I'm putting together a quick little app just to do some messaging
between users. I'm trying to do it restfully but what I have feels kind
Here's what I have:
User has_many :messages
Message belongs_to :user ; belongs_to :msgcontent
Msgcontent has_many :messages
Message is a join model between User and Msgcontent. In addition to
containing references to User and Msgcontent, it also has a "status"
field indicating whether a given user has read or deleted the message.
This is the only reason for the join model. It saves having to have the
same content for a message replicated multiple times in the database.
The UsersController and SessionsController come from the
restful_authentication plugin. Note that there is _no_
The intent is to have the following urls, but it feels dirty since it's
mixing the Message and Msgcontent models together in the
MessagesController. It does leave the url space fairly clean.
* GET /messages # retrieves messages & msgcontent for current
* POST /messages # creates single msgcontent and a message for
* GET /messages/1 # retrieves message 1 and related msgcontent
* PUT /messages/1 # updates the status of message 1 (read/unread
* DELETE /messages/1 # deletes message 1 and if no more references
to related msgcontent, removes that as well.
* GET /messages/new # form containing info for _msgcontent_
* GET /messages/1/edit # possible form for _message_ to update
I'm looking for alternate ways to solve this type of solution. Or is
this how it would be done?