質問

I am developing a feeds application with ruby on rails, and I want to show in the main page of the application some courses activities managing by the users.

Basically, the idea is a user can create a course, other users can follow the course and comment inside that event, later in the future, I Want that it will be more complex.

My solution is having a notifications table which manage all this. Above it shows the table which will have a feed type (1. create course, 2. pay the course, 3. comment into this group, 4. course deleted, 5. share course... and could be more). user_id field refiere to the user who should see the notification, message_id not nil only when the notification consist in add a comment.

<<Table>>
Feed
----------------
+ id : integer (Pk)
+ created_at : date_time
+ notification_type : string
+ text : text
+ course_id : integer (Fk)
+ user_id : integer (Fk)
+ comment_id : integer (Fk)

I am wondering if that would be the best implementation of this problem if I Want to make it more complex in the future. Please any feedback is welcome!

Thank you!

役に立ちましたか?

解決

You're implementing the observer patter for this application. Based on your requirements, it looks like a fine implementation.

Here are some resources about this pattern.

http://www.sitepoint.com/design-patterns-in-ruby-observer-singleton/

Implementing Observer Pattern for my Rails App

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top