3

How can I mark any message as read in mailboxer?

Even if I add the line: <% conversation.mark_as_read(current_user) %> in my view, it does not solve my problem.

Surya
  • 15,703
  • 3
  • 51
  • 74
Faizan
  • 105
  • 15
  • Could you please describe the issue in more detail?? like: where you're trying to add `<% conversation.mark_as_read(current_user) %>` and what view/controller/model etc? – Surya Dec 31 '13 at 06:28
  • i m trying to understand how sample app (https://github.com/RKushnir/mailboxer-app) uses mailboxer. I added <% conversation.mark_as_read(current_user) %> in show page of conversations controller. My major problem is how can i set the read attribute of a receipt when a user has seen the message in his inbox.If i set read=true manually,i get an :read only attribute" error.I want unread count basically . – Faizan Dec 31 '13 at 06:39
  • It works now.Not sure what the problem was but anyways it works with the same line conversation.mark_as_read(current_user) but this code should be added in view and not the controller because it only belongs to the views and not the controllers. – Faizan Dec 31 '13 at 06:57
  • I was going through this: https://github.com/frodefi/rails-messaging to see if anything is related. however I didn't find any code which line: `<% conversation.mark_as_read(current_user) %> ` in the sample app's github link you posted. Anyway, I am glad that your issue is resolved. – Surya Dec 31 '13 at 07:09
  • Thanks but the link was https://github.com/RKushnir/mailboxer-app and you have to add this line <% conversation.mark_as_read(current_user) %> manually to mark a conversation as read in show page of conversations controller because if u dont,all the messages will be marked unread even after a user views all those messages.Not sure why they did not add it themselves on github.But when i added this,the app worked fine and i am now able to get the unread message count. – Faizan Dec 31 '13 at 07:19
  • I checked https://github.com/RKushnir/mailboxer-app repository for the mentioned method. link github.com/frodefi/rails-messaging was something related so I thought it might have what you're looking for. – Surya Dec 31 '13 at 07:22

1 Answers1

2

In case anybody else has this issue in the future, the solution is to only put code like what is in the original question in something like MessagesController, and to create a form which points to that action.

Amar H-V
  • 1,316
  • 3
  • 20
  • 33