Ruby on Rails Monday, September 25, 2017



On Monday, September 25, 2017 at 6:28:17 AM UTC-4, Colin Law wrote:
On 25 September 2017 at 11:13, fugee ohu <fuge...@gmail.com> wrote:
> Here
> https://stackoverflow.com/questions/44417543/mailboxer-recipient-inbox-not-showing-conversations
> someone shows how to send a message to a recipient_id rather than a
> recipient object My understanding is recipients has to be an object so how
> can his example work?

Which line of code is sending a message to a recipient_id?

Colin

Under answer:

1 Answer


I make it working finally, here is my code, maybe it can help other:

(i'm on rails 5)

The link on my product page:

<%= link_to "Contactar", new_conversation_path(recipient_id: service.user.id) %>

My new and create action on my conversation controller:

 def new   @recipients = User.find(params[:recipient_id])     end     def create   recipient = User.find_by(id: params[:recipient_id])   receipt = current_user.send_message(recipient, params[:body],    params[:subject])   redirect_to conversation_path(receipt.conversation)   end
 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e5028f7a-db69-4555-965f-a388382e69cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment