mailboxer | A Rails gem to send messages inside a web application
kandi X-RAY | mailboxer Summary
kandi X-RAY | mailboxer Summary
This project is based on the need for a private message system for ging / social_stream. Instead of creating our core message system heavily dependent on our development, we are trying to implement a generic and potent messaging gem. After looking for a good gem to use we noticed the lack of messaging gems and functionality in them. Mailboxer tries to fill this void delivering a powerful and flexible message system. It supports the use of conversations with two or more participants, sending notifications to recipients (intended to be used as system notifications “Your picture has new comments”, “John Doe has updated his document”, etc.), and emailing the messageable model (if configured to do so). It has a complete implementation of a Mailbox object for each messageable with inbox, sentbox and trash. The gem is constantly growing and improving its functionality. As it is used with our parallel development ging / social_stream we are finding and fixing bugs continously. If you want some functionality not supported yet or marked as TODO, you can create an issue to ask for it. It will be great feedback for us, and we will know what you may find useful in the gem. Mailboxer was born from the great, but outdated, code from lpsergi / acts_as_messageable. We are now working to make exhaustive documentation and some wiki pages in order to make it even easier to use the gem to its full potential. Please, give us some time if you find something missing or ask for it. You can also find us on the Gitter room for this repo. Join us there to talk.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- send the message to the set
- Invoke receipt .
- Get a conversation list of recipients
- Send the email
- configure the mailer method
- Return the mailer from the client .
mailboxer Key Features
mailboxer Examples and Code Snippets
Community Discussions
Trending Discussions on mailboxer
QUESTION
I am using Noticed gem for my notifications and I am trying to query for the notifications related to the post. The notification stores the post as an object inside params.
...ANSWER
Answered 2021-May-14 at 18:56It seems the gem creates either a jsonb or json column depending on your db. So what want is perform a search on a json(b) column
For postgres for example it can be done like this
QUESTION
I would like to add a new participant(not current_user
) to one of my conversations.
I created a conversation with
...ANSWER
Answered 2021-Apr-04 at 07:53I just found a method in source code, which does the job.
QUESTION
This works...
...ANSWER
Answered 2019-Aug-08 at 20:26While I cannot answer your actual question as to why these are incompatible I can offer a solution akin to your raw SQL example.
You can perform the same operation like so
QUESTION
My problem is that when users reply to each other, it's hard examine the database via SQL and differentiate between user types (so admin, and individual users). The default is just "User", as a string.
When examining the mailboxer code, I know it calls the "reply" method in the Conversations controller. This is the relevant part of the code:
...ANSWER
Answered 2019-May-14 at 21:16In the code you proposed, you are calling sender_type
on the array of messages, but that method exists on the Mailboxer::Message
model. As it's a polymorphic association see code of model here, the sender
of the Mailboser::Message
will be the user that was used for creating the message (in this case current_user
).
So I guess what you are looking for, is to get the user_type
of your sender for a specific message of a conversation.
So this is can be done, by doing the following (in this example let's get the user_type
of the user that sent the first message of a given conversation :
QUESTION
Question: How can I have a 'Message not read' appear next to each message within my inbox?
I have created an internal mailing system for my app, using the mailboxer gem. My issue is when I go into the inbox section, and view all the messages that have been sent to my user account, I want to be able to see which messages I have not read.
My code:
...ANSWER
Answered 2019-Jan-25 at 01:09actually mailboxer has method in conversation record is_unread?(current_user) you can use it for your task above
below for example your conversations controller
QUESTION
QUESTION: How can I have the recipient field, automatically filled out, with a user's username, for example, using the MailBoxer gem?
I have a user admin account, and I want to have the recipient field pre-filled out, when I click on a user (non admin) profile page, in the show.html.erb view.
Currently, the code used displays ALL users utilising the platform, whereas I want this specific form to only display the recipient.
I am using the mailboxer gem, and I have the subject and message field already pre-filled and working.
The code for the form, which is in the show.html.erb view:
...ANSWER
Answered 2019-Jan-24 at 02:00you can use attribute selected :selected => @user.id (based your code above you have @user)
QUESTION
I am using the mailboxer gem in rails for an app. It shows how to create a mailbox page in which I can send messages to other users. But I want to know how to add these options for other pages.
For example, a send message button on a user's profile page (to send a message to that user).
Allowing a user to send a message to the poster of a post/story (from the stories gem).
etc..
How do I do this?
The tutorial is https://www.sitepoint.com/messaging-rails-mailboxer/
...ANSWER
Answered 2017-Apr-23 at 08:17The tutorial has an addendum that covers most of what you are seeking but adds the button to the user index page. Based on the author's approach here is the answer specifically to your query. This is assuming you finished the original tutorial and it is working fine.
In the messages_controller's 'new' action, create an instance variable called @chosen_recipient that gets the user id from a query string if it is present. The format of a query string following the path is ?key=value so something like localhost:3000/messages/new?to=1.
QUESTION
I'm using the mailboxer gem to build a messaging system between users for my rails application. For some reason, I'm getting this error:
(undefined method `receipts_for' for nil:NilClass)
Maybe it's because I should define 'receipts_for' somewhere in my controller or in the mailboxer.rb? I tried a few things.. but unfortunately none of them were successful.
This is my routes.rb:
...ANSWER
Answered 2018-May-29 at 13:53I’ll piggy-back on what @mu is too short said. It’s important to pay attention to the whole error message. “undefined method receipts_for for nil:NilClass” is telling you that the receiver of the receipts_for
method is nil. @conversation.receipts_for(current_user)
looks to be the only place where receipts_for
is used, so I would start debugging by making sure @conversation
is assigned the value of an existing ActiveRecord-backed conversation object.
There seems to be too a lot going on, so I don't know how to offer you a quick fix. The value assignment in your ConversationsController#show
method, @conversation= current_user.mailbox.conversation.find(params[:id])
looks cumbersome. That suggests to me that you're looking for a conversation
based on a mailbox
belonging to the current_user
, which might be what you want (in which case, you need to have the appropriate associations defined in your models).
However, since the chain ends with conversation.find(params[:id])
, I'm guessing that current_user.mailbox
is not needed. Alternatively, if your params
don't actually have a conversation id, then maybe that's what you need to focus on.
The good news is you can probably figure out how to define @conversation
if you stick byebug (or binding.pry, depending on what you have installed) at the top of your show
method and in your view partial:
QUESTION
i keep getting this missing template error
...ANSWER
Answered 2018-Feb-01 at 13:04This error comes if you're hitting the create
action using HTML. create
doesn't typically have an associated view; you use it to process an entity, and redirect the user elsewhere.
Therefore, you should just be able to use:
QUESTION
I managed to install Mailboxer with this tutorial but i have a recurring error :
...ANSWER
Answered 2017-Jul-20 at 05:33Normally, to fix these N+1 query problems we use an includes
and by passing a hash, we can includes
nested associations. So looking at this code, calling receipt.message.sender
is triggering the error, so we have a Receipt
model, a message
association on it and a sender
associated to that. So if we can find where we load the Receipt
we can add includes(message: :user)
like we would for any other model.
Digging into the mailboxer gem, the receipts_for
method in your show
action is just a wrapper for a couple of scopes on Mailboxer::Receipt
. Since this method just runs some scopes for you, we can chain onto the end of it as if it were a normal ActiveRecord
where
chain.
So with all that in mind, we should be able to add on our includes
and avoid the N+1 query problem, ending up with something like
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install mailboxer
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page