Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation Between User and current user #485

Open
SunnyAforka opened this issue Jul 2, 2018 · 2 comments
Open

Conversation Between User and current user #485

SunnyAforka opened this issue Jul 2, 2018 · 2 comments

Comments

@SunnyAforka
Copy link

I am thinking of how to auto fill recipient with @user of a current page so the the current user does not have to search or select user to send a message to.
For example i have created a page for each user like a profile page, Then a current user visits another user's page would just see a mail-boxer form to type message without typing or searching recipient, just hits send and it goes straight to the @user mail-boxer inbox so then a conversation between the @user and current_user is established.
I don't know if i am understood!

@SunnyAforka SunnyAforka changed the title Conversation Between User and and current user Conversation Between User and current user Jul 2, 2018
@domi91c
Copy link

domi91c commented Jul 28, 2018

Is it not just a matter of setting the recipient to that user? You can pass the ID of that user to your conversations controller with a hidden field, for example.

In your conversations controller:

def create
  recipient = User.find(params[:recipient_id])
  current_user.send_message(recipient, params[:body], params[:subject])
  redirect_to conversations_path
end

Somewhere in your users/show.html.erb view:

<%= form_tag conversations_path, method: :post do %>
  <%= hidden_field :recipient_id, @user.id %> # pass the user id as recipient_id param

  <p><%= text_field_tag :subject, nil, placeholder: "Subject" %></p>
  <p><%= text_area_tag :body, nil, placeholder: "Say hi..." %></p>

  <%= submit_tag %>
<% end %>

@SunnyAforka
Copy link
Author

SunnyAforka commented Mar 8, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants