{"id":13880493,"url":"https://github.com/LTe/acts-as-messageable","last_synced_at":"2025-07-16T17:30:23.183Z","repository":{"id":1000407,"uuid":"812421","full_name":"LTe/acts-as-messageable","owner":"LTe","description":"Gem that allows communication between the models.","archived":false,"fork":false,"pushed_at":"2025-02-17T08:51:33.000Z","size":11842,"stargazers_count":253,"open_issues_count":15,"forks_count":57,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-06-22T08:06:59.017Z","etag":null,"topics":["conversation","inbox","messaging","rails","ruby"],"latest_commit_sha":null,"homepage":"http://lte.github.io/acts-as-messageable/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LTe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2010-08-02T14:41:30.000Z","updated_at":"2024-10-15T13:16:02.000Z","dependencies_parsed_at":"2024-03-27T05:31:10.243Z","dependency_job_id":"b3dc4ba5-6bfb-41c1-a503-f37841d51337","html_url":"https://github.com/LTe/acts-as-messageable","commit_stats":{"total_commits":530,"total_committers":19,"mean_commits":"27.894736842105264","dds":0.5207547169811321,"last_synced_commit":"b525c3139068b34e3d26f30bec57a8ecb82d4c65"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/LTe/acts-as-messageable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LTe%2Facts-as-messageable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LTe%2Facts-as-messageable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LTe%2Facts-as-messageable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LTe%2Facts-as-messageable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LTe","download_url":"https://codeload.github.com/LTe/acts-as-messageable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LTe%2Facts-as-messageable/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265527540,"owners_count":23782480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conversation","inbox","messaging","rails","ruby"],"created_at":"2024-08-06T08:03:04.796Z","updated_at":"2025-07-16T17:30:22.776Z","avatar_url":"https://github.com/LTe.png","language":"Ruby","readme":"# ActsAsMessageable\n\nActsAsMessageable is a Ruby gem that provides a flexible and robust messaging system between models in Rails \napplications. With this gem, you can easily implement features such as private messaging between users, \nconversations, message search, and much more. This gem is perfect for applications where communication between \nusers or other models is required.\n\n[![Build Status](https://github.com/LTe/acts-as-messageable/actions/workflows/test.yml/badge.svg)](https://github.com/LTe/acts-as-messageable/actions/workflows/test.yml)\n[![Code Climate](https://codeclimate.com/github/LTe/acts-as-messageable.png)](https://codeclimate.com/github/LTe/acts-as-messageable)\n[![Coverage Status](https://coveralls.io/repos/LTe/acts-as-messageable/badge.png?branch=master)](https://coveralls.io/r/LTe/acts-as-messageable?branch=master)\n[![Gem Version](https://badge.fury.io/rb/acts-as-messageable.png)](http://badge.fury.io/rb/acts-as-messageable)\n\n\u003c!-- START_TOC --\u003e\n* [ActsAsMessageable](#actsasmessageable)\n* [Usage](#usage)\n    * [Rails \u003e= 3](#rails--3)\n    * [Rails 2](#rails-2)\n* [Post installation](#post-installation)\n* [Usage](#usage-1)\n* [Upgrade](#upgrade)\n* [Send message](#send-message)\n  * [With hash](#with-hash)\n* [Custom required (validation)](#custom-required-validation)\n  * [With hash](#with-hash-1)\n  * [Normal](#normal)\n  * [Required sequence](#required-sequence)\n  * [First topic](#first-topic)\n* [Custom class](#custom-class)\n* [Conversation](#conversation)\n  * [Get conversation for a specific message](#get-conversation-for-a-specific-message)\n* [Search](#search)\n    * [Search text from messages](#search-text-from-messages)\n    * [Inbox](#inbox)\n    * [Outbox](#outbox)\n    * [Trash](#trash)\n  * [Filters](#filters)\n* [Read messages](#read-messages)\n    * [Read message](#read-message)\n    * [Unread message](#unread-message)\n* [Delete message](#delete-message)\n  * [Delete message without context](#delete-message-without-context)\n* [Restore message](#restore-message)\n  * [Restore message without context](#restore-message-without-context)\n* [Group message](#group-message)\n  * [Enable group messages](#enable-group-messages)\n  * [How to join other users's conversation](#how-to-join-other-userss-conversation)\n  * [Know the people involved in conversation](#know-the-people-involved-in-conversation)\n* [Search](#search-1)\n  * [Search text from messages](#search-text-from-messages-1)\n* [License](#license)\n* [Contributing](#contributing)\n\u003c!-- END_TOC --\u003e\n\n# Usage\n\nTo use it, add it to your Gemfile:\n\n### Rails \u003e= 3\n\n```ruby\ngem 'acts-as-messageable'\n```\n\n### Rails 2\n\nUse this [fork](http://github.com/openfirmware/acts-as-messageable)\nThanks for [@openfirmware](http://github.com/openfirmware)\n\n```ruby\ngem 'acts-as-messageable', :git =\u003e 'git://github.com/openfirmware/acts-as-messageable.git',\n                           :branch =\u003e 'rails2.3.11_compatible'\n```\n\n# Post installation\n\n```\nrails g acts_as_messageable:migration [messages] [--uuid]\nrake db:migrate\n```\n\nYou need to run migration generator to create tables in database. You can do this with the `acts_as_messageable:migration`\ngenerator. Default table name is `messages`, you can pass table name and uuid option to enable `uuid` support (by \ndefault disabled). UUID support is required in case when your user primary key is `uuid` type.\n\n**Create `messages` table without `uuid` support**\n```\nrails g acts_as_messageable:migration \n```\n\n**Create `messages` table with `uuid` support**\n```\nrails g acts_as_messageable:migration --uuid\n```\n\n**Create `my_messages` table without `uuid` support**\n```\nrails g acts_as_messageable:migration my_messages\n```\n\n**Create `my_messages` table with `uuid` support**\n```\nrails g acts_as_messageable:migration my_messages --uuid\n```\n\n# Usage\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  acts_as_messageable :table_name =\u003e \"table_with_messages\", # default 'messages'\n                      :required   =\u003e :body,                 # default [:topic, :body]\n                      :class_name =\u003e \"CustomMessages\",      # default \"ActsAsMessageable::Message\",\n                      :dependent  =\u003e :destroy,              # default :nullify\n                      :group_messages =\u003e true,              # default false\n                      :search_scope =\u003e :custom_search       # default :search\nend\n```\n\n# Upgrade\n\nJust type once again\n\n```\nrails g acts-as-messageable:migration\n```\n\nAnd new migrations should be created.\n\n```\n~$ rails g acts-as-messageable:migration\n    create  db/migrate/20110811223435_add_recipient_permanent_delete_and_sender_permanent_delete_to_messages.rb\n```\n\n# Send message\n\n```ruby\n@alice = User.first\n@bob   = User.last\n\n@alice.send_message(@bob, \"Message topic\", \"Hi bob!\")\n@bob.send_message(@alice, \"Re: Message topic\", \"Hi alice!\")\n```\n\n## With hash\n\n```ruby\n@alice.send_message(@bob, { :body =\u003e \"Hash body\", :topic =\u003e \"Hash topic\" })\n```\n\n# Custom required (validation)\n\nIn User model\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  acts_as_messageable :required =\u003e :body\nend\n```\n\n## With hash\n\n```ruby\n@alice.send_message(@bob, { :body =\u003e \"Hash body\" })\n```\n\n## Normal\n\n```ruby\n@alice.send_message(@bob, \"body\")\n```\n\n## Required sequence\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  acts_as_messageable :required =\u003e [:body, :topic]\nend\n\n@alice.send_message(@bob, \"body\", \"topic\")\n```\n\n## First topic\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  acts_as_messageable :required =\u003e [:topic, :body]\nend\n\n@alice.send_message(@bob, \"topic\", \"body\")\n```\n\n# Custom class\n\nYou can use your own class that will represent the message object. First of all create custom class\n\n```ruby\nclass CustomMessage \u003c ActsAsMessageable::Message\n  def capitalize_title\n    title.capitalize\n  end\nend\n```\n\nAfter that you can sepcify custom class in options.\n\n```ruby\nclass User\n  acts_as_messageable :class_name =\u003e \"CustomMessage\"\nend\n```\n\nFrom now on, your message has custom class.\n\n```ruby\n@message = @alice.send_message(@bob, \"hi!\")\n@message # =\u003e #\u003cCustomMessage:0x000000024b6278\u003e\n@message.capitalize_title # =\u003e \"Hi!\"\n```\n\n# Conversation\n\nYou can get a conversation list from messages scope. For example:\n\n```ruby\n@message = @alice.send_message(@bob, \"Hello bob!\", \"How are you?\")\n@reply_message = @bob.reply_to(@message, \"Re: Hello bob!\", \"I'm fine!\")\n\n@alice.received_messages.conversations # =\u003e [@reply_message]\n```\n\nThis should receive list of latest messages in conversations.\n\nTo create conversation just reply to a message.\n\n```ruby\n@message = @alice.send_message(@bob, \"Hello bob!\", \"How are you?\")\n@message.reply(\"Re: Hello bob!\", \"I'm fine\")\n```\n\n**Or with hash**\n\n```ruby\n@message.reply(:topic =\u003e \"Re: Hello bob!\", :body =\u003e \"I'm fine\")\n```\n\n**Or in old style**\n\n```ruby\n@message = @alice.send_message(@bob, \"Hello bob!\", \"How are you?\")\n@reply_message = @bob.reply_to(@message, \"Re: Hello bob!\", \"I'm fine!\")\n```\n\n## Get conversation for a specific message\n\n```ruby\n@message.conversation       #=\u003e [@message, @reply_message]\n@reply_message.conversation #=\u003e [@message, @reply_message]\n```\n\n# Search\n\nYou can search for text within messages and get the records where a match exists.\n\n### Search text from messages\n\n```ruby\nrecords = @alice.messages.search(\"Search me\") # @alice searches for the text \"Search me\" in all messages\"\n```\n\n### Inbox\n```ruby\n@alice.received_messages\n```\n\n### Outbox\n```ruby\n@alice.sent_messages\n```\n### Inbox + Outbox. All messages connected with __@alice__\n```ruby\n@alice.messages\n```\n\n### Trash\n```ruby\n@alice.deleted_messages\n```\n\n## Filters\n\n```ruby\n@alice.messages.are_from(@bob) # all message from @bob\n@alice.messages.are_to(@bob) # all message to @bob\n@alice.messages.with_id(@id_of_message) # message with id id_of_message\n@alice.messages.readed # all read @alice messages\n@alice.messages.unreaded # all unreaded @alice messages\n```\n\n**You can use multiple filters at the same time**\n\n```ruby\n@alice.messages.are_from(@bob).are_to(@alice).readed # all message from @bob to @alice and readed\n@alice.deleted_messages.are_from(@bob) # all deleted messages from @bob\n```\n\n# Read messages\n\n### Read message\n\n```ruby\n@message.open # open message\n@message.read\n@message.mark_as_read\n```\n\n### Unread message\n\n```ruby\n@message.close # unread message\n@message.mark_as_unread\n```\n\n\n# Delete message\n\n**__We must know who deleted the message. That's why we use the *.process* method to save context__**\n\n```ruby\n@message = @alice.send_message(@bob, \"Topic\", \"Body\")\n\n@alice.messages.process do |message|\n  message.delete # @alice delete message\nend\n```\n\nNow we can find the message in the **trash**\n\n```ruby\n@alice.deleted_messages #=\u003e [@message]\n```\n\nWe can delete the message **permanently**\n\n```ruby\n@alice.deleted_messages.process do |message|\n  message.delete\nend\n\n@alice.delete_message #=\u003e []\n```\n\nThe message has been deleted **permanently**\n\n## Delete message without context\n\n```ruby\n@alice.delete_message(@message) # @alice delete @message\n```\n\n# Restore message\n\n```ruby\n@alice.deleted_messages.process do |m|\n  m.restore # @alice restore 'm' message from trash\nend\n```\n\n## Restore message without context\n\n```ruby\n@alice.restore_message(@message) # @alice restore message from the trash\n```\n\n# Group message\n\n## Enable group messages\n\n```ruby\nclass User\n  acts_as_messageable :group_messages =\u003e true\nend\n```\n\n## How to join other users's conversation\n\n```ruby\n@message =  @alice.send_message(@bob, :topic =\u003e \"Helou bob!\", :body =\u003e \"What's up?\")\n@reply_message = @sukhi.reply_to(@message, \"Hi there!\", \"I would like to join to this conversation!\")\n@sec_reply_message = @bob.reply_to(@message, \"Hi!\", \"Fine!\")\n@third_reply_message = @alice.reply_to(@reply_message, \"hi!\", \"no problem\")\n```\n\n## Know the people involved in conversation\n\n```ruby\n@message.people # will give you participants users object\n@message.people # =\u003e [@alice, @bob, @sukhi]\n```\n\n# Search\n\n## Search text from messages\n\n```ruby\n@alice.messages.search(\"Search me\") # @alice searches for the text \"Search me\" in all messages\"\n```\n\n# License\n\nActsAsMessageable is released under the MIT License. See the bundled LICENSE file for details.\n\n# Contributing\n\nContributions are welcome! To contribute:\n\n1. Fork the project.\n2. Create your feature branch (`git checkout -b my-new-feature`).\n3. Commit your changes (`git commit -am 'Add some feature'`).\n4. Push to the branch (`git push origin my-new-feature`).\n5. Create a new Pull Request.\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLTe%2Facts-as-messageable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLTe%2Facts-as-messageable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLTe%2Facts-as-messageable/lists"}