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 6111725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:39:49+00:00 2026-05-23T14:39:49+00:00

I want to create users dialog How I must do? Create one record with

  • 0

I want to create users dialog

How I must do?

Create one record with sender_id and recipient_id and then “select * from table_dialog where sender_id=current.id or recipient_id =current.id” also add 2 columns deleted_by_sender and deleted_by_recipient

Or create 2 record in database for each dialog

What is the best solution? Or propose your own solution please

  • 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-05-23T14:39:50+00:00Added an answer on May 23, 2026 at 2:39 pm

    If by “dialog” you mean a “conversation between TWO participants”, then it is very similar to classic mailbox. The following code extract(with abbreviation) from one of my project which implements similar functionality. Maybe will be helpful.

    class User < ActiveRecord::Base
      # ....
      has_many :received_messages, :class_name => "Message", :foreign_key => 'recipient_id'
      has_many :sent_messages, :class_name => "Message", :foreign_key => 'sender_id'
      # ....
    end
    
    class Message < ActiveRecord::Base
      validates :content, :presence => true
      validates :sender, :presence => true, :associated => true
      validates :recipient, :presence => true, :associated => true
    
      belongs_to :sender, :class_name => 'User', :foreign_key => 'sender_id'
      belongs_to :recipient, :class_name => 'User', :foreign_key => 'recipient_id'
    
      default_scope order('created_at desc')
    
      # usage: user.received_messages.unread
      scope :unread, where('unread = true')
    
      def self.chat_between(first_user, second_user)
        where('(recipient_id = ? AND sender_id = ?) OR (recipient_id = ? AND sender_id = ?)',
                first_user.id, second_user.id, second_user.id, first_user.id)
      end
    
      def self.read_all!
        self.update_all('unread = false')
      end
    
      def read!
        self.update_attribute :unread, false
      end
    
      def new?(user)
        (recipient == user) && (unread == true)
      end
    
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a function which grabs every users latest tweet from a
In my application, I want to create a dialog box with one text field,
I want to create a warning dialog box which asks the users if the
Hai I want to create more users as admin and allow permission to access
I want to create a website with various users. The users can have different
I want to create a web application that allows users to sign up, register
I want to create a login dialog by inheriting QDialog. I put in subclass
In a Ruby-on-Rails website, I want to create the following dialog, where a user
I want to create a dialog with a pointer which points to where the
I want to create my own simple alert dialog with jQuery. Two problems: how

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.