Read posts for user |
Форум Форуліо→ Forulio→ Tips & Tricks→ Read posts for user
|
|
додано більше 2 років тому (13 Березня 2008 о 8:11)
As this is the first topic in this section, i would like to explain what it about. While developing Forulio we solve some issues. Hope that our solutions can help someone too. Actually, all the code is going to be public after our first release, but anyway it is better to read article then code
![]() So first issue is how to show for each user which topic was read by him and which is not. First, I created new model that will store last_read_post_id for each user and for each topic:
Then every time user open topic, let's save this action to ReadTopic, method is in User model:
In appropriate view add this line: <%current_user.read_topic(@topic) unless current_user.nil?%> Now let's show topics in specific forum. Every unread topic can be checked be method in Topic model:
Last thing is to add last_read_post property to Topic model that should be user specific. To do this we do special find if controller:
The last thing is that last_read_post property in Topic model is dynamic and user specific. There is no field with this name in topics table. To define this attribute in Topic model:
That is all. |
|
|
додано блилько року тому (13 Листопада 2008 о 4:00)
sVZXvCV
|
|
|
додано блилько року тому (13 Листопада 2008 о 15:51)
very good!
|
|
|
додано блилько року тому (18 Червня 2009 о 22:26)
a test post edited !
|
|
|
додано блилько року тому (18 Червня 2009 о 22:27)
|
|
|
додано блилько року тому (21 Червня 2009 о 12:24)
sazwqa написав(ла) test reply |
|
|
додано 5 місяців тому (23 Березня о 13:58)
|
Увійдіть або Зареєструйтесь
Щоб додавати записи до теми.
