User to user private messaging system integration

I came across this site for a list of private messaging gems https://www.ruby-toolbox.com/categories/User_Messaging_Systems and in particular I thought this might be the one to go for: https://github.com/mailboxer/mailboxer because 1) it provides emails as a notification when a user receives a message on the app 2) mailbox can be used in other models such as listing and not only users. Everything about this gem looks great and I'm trying to implement this. In the context of etsydemo course where each listing will have 'message me!' button in its show.html.erb page, it looks quite clear that I need to add 'act_as_messageable' to the listing.rb model file. From reading 'how can I send a message section?' i was thinking that i should write into views/listings/show.html.erb the following code? user.send_message(beta, "Body", "subject") but i guess I need to somehow define this 'send_message' function in listing.controller file but the github page doesn't specify this... It seems to me that that there should be more code that needs to be added rather than the two 'act_as_messageable' and 'user.send_message(beta, "Body", "subject"). I would much appreciate if you could let me know whether I am taking the right direction in implementing this gem thank you! Harry

Posted almost 6 years ago by Harry Lee
Posted almost 6 years ago by Alex Yang

Harry, I haven't used the mailboxer gem before, but I took a quick look at the gem page to see if I could help make sense of the documentation. It seems to me like the 'send_message' method has already been defined for the gem, but you should call this method from your controller file, not from your view page.

You can see an example of someone overriding the 'send_message' method in this link: https://github.com/mailboxer/mailboxer/issues/65.

0