Module: Denshobato::ConversationHelper
- Included in:
- CoreHelper
- Defined in:
- lib/denshobato/helpers/core_modules/conversation_helper.rb
Instance Method Summary collapse
- #find_conversation_with(user) ⇒ Object
- #make_conversation_with(recipient) ⇒ Object
- #my_conversations ⇒ Object
- #trashed_conversations ⇒ Object
Instance Method Details
#find_conversation_with(user) ⇒ Object
24 25 26 27 28 |
# File 'lib/denshobato/helpers/core_modules/conversation_helper.rb', line 24 def find_conversation_with(user) # Return an existing conversation between sender and recipient hato_conversation.find_by(sender: self, recipient: user) end |
#make_conversation_with(recipient) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/denshobato/helpers/core_modules/conversation_helper.rb', line 16 def make_conversation_with(recipient) # Build conversation # = form_for current_user.make_conversation_with(recipient) do |f| # = f.submit 'Start Chat', class: 'btn btn-primary' hato_conversations.build(recipient: recipient) end |
#my_conversations ⇒ Object
3 4 5 6 7 8 |
# File 'lib/denshobato/helpers/core_modules/conversation_helper.rb', line 3 def my_conversations # Return active user conversations (which is not in trash) trashed = block_given? ? yield : false hato_conversation.my_conversations(self, trashed) end |
#trashed_conversations ⇒ Object
10 11 12 13 14 |
# File 'lib/denshobato/helpers/core_modules/conversation_helper.rb', line 10 def trashed_conversations # Return trashed conversations my_conversations { true } # => hato_conversation.where trashed: true end |