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)
|
Войдите или Зарегистрируйтесь
Чтобы отвечать в тему.
