Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8746085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:08:23+00:00 2026-06-13T12:08:23+00:00

Users are able to send each other messages on my Ruby app. The table

  • 0

Users are able to send each other messages on my Ruby app. The table is as followed:

t.string   "content"
t.integer  "from_id"
t.integer  "reply_to_id"
t.boolean  "read",       :default => false

I have recently added the boolean, :read, and I have the form linked to messages in their inbox. When they click “Mark Read” (the link provided via the form) I want it to toggle :read => true.

I am currently unable to accomplish this. This is my current setup.

_mark_read.html.erb
  <%= form_for(:message, :mark_read => {read: true}) do |f| %>
    <div><%= f.hidden_field :read %></div>
    <%= f.submit "Mark Read", class: "btn-link" %>
  <% end %>

Class MessagesController < ApplicationController
  def mark_read
    @message = current_user.messages.build
    @message.toggle!(:read)
  end

config/routes.rb
 match '/mark_read' => 'messages#mark_read', :via => :post, :as => :mark_read

When I click “Mark Read”, here is my debug info:

--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
utf8: ✓
authenticity_token: ---
message: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
  read: 'false'
commit: Mark Read
controller: static_pages
action: connect

I can see it is not even using my controller… and even so; I don’t think I have it set up correctly.

Any advise as to how this should be set up would be kindly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:08:24+00:00Added an answer on June 13, 2026 at 12:08 pm

    Believe it or not.. I didn’t even need a model, nor controller 😀 As I said it is rendered within a paginated set. This paginated set is defined at @inbox_items identified as inbox_item.id.

    Here is the form that works without any need of a model or controller. It is simply defined in config/routes.rb as:

    match '/mark_read' => 'messages#mark_read', :via => :post
    

    The form:

    <ul class="share-actions" id="mark_read<%= inbox_item.id %>">
      <%= form_for :mark_read do |f| %>  
        <%= f.check_box inbox_item.toggle!(:read) %>
        <%= f.submit "Mark Read", class: "btn btn-link" %>
      <% end %>
    </ul>
    

    Ammusing, huh? 😀

    More information in-case you are curious. The base Class of rendered @inbox_items, is Class Message. Messages define all of user’s private posts. In the User class I begin to set up how @inbox_items will be defined:

    Class User
      def inbox
        Message.from_users_inbox(self)
      end
    

    Then I build the rest:

    Class Message
      def self.from_users_inbox(user)
        "SELECT best_friend_id FROM friendships WHERE new_friend_id = :user_id"
        where("user_id = :user_id OR reply_to_id = :user_id", user_id: user.id)
      end
    
    MemberpagesController
      def inbox
        @message = current_user.messages.build
        @inbox_items = current_user.inbox.paginate(page: params[:page])
      end
    
    feeds/_inbox.html.erb
      <% if @inbox_items.any? %>
        <%= render: 'feeds/inbox_item', collection: @inbox_items %>
        <%= will_paginate @inbox_items %>
      <% end %>
    

    And finally:

    feeds/_inbox_item.html.erb
      <div id="<%= inbox_item.user.name %>_<%= inbox_item.id %>">
      ...
        <ul class="share-actions" id="mark_read<%= inbox_item.id %>">
          <%= form_for :mark_read do |f| %>  
            <%= f.check_box inbox_item.toggle!(:read) %>
            <%= f.submit "Mark Read", class: "btn btn-link" %>
          <% end %>
       </ul>
    ...
    

    And that did it! 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to have individual users send messages to each other
In the website on which I'm working, users may send messages to each other.
I have an app where we want users to be able to send us
In my app, users are able to quickly switch back and forth between objects
I want to create an example SaaS app, whereby users are able to signup,
My application is storing some data in SQL Table called Transactions. Users are able
I'm building an app that requires private messaging functionality for users to message each
I want users to be able to use the facebook send button to send
When a button is clicked, the end user is able to send an email.
Im storing columns in database with users able to add and remove columns, with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.