5

I spent day and day to figure out how to make good messaging system between registered member via devise.

But in all cases, those gems are out of date and they don't support rails3.

If you guys are trying to make the system, which include these function. How do you make?

  1. Member registration (devise)
  2. private messaging system (with acition mailer)
MKK
  • 2,713
  • 5
  • 31
  • 51

2 Answers2

5

https://github.com/ging/mailboxer ?

/config/initializer/mailboxer.rb :

Mailboxer.setup do |config|
  config.uses_emails = true  
  config.default_from = "no-reply@youraddress.com"
end

minimal model

class User < ActiveRecord::Base
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  acts_as_messageable

  attr_accessible :email, :password, :password_confirmation, :remember_me

  def name
    email
  end

  def mailboxer_email(object)
    email
  end  
end

And of course starndard mailer configurations.

dimuch
  • 12,728
  • 2
  • 39
  • 23
  • Thanks, I tried it and it works pretty well. but the problem is that it doesn't deliver email :( – MKK Jun 20 '12 at 06:23
  • It does, have you configured it? I'll edit the answer to show required changes. – dimuch Jun 20 '12 at 06:48
  • Thanks, dimuch. It seemed that I succeed at install. Then I reffered the sample here( https://github.com/RKushnir/mailboxer-app ) But, unfortunately, it's written with haml that I wouldn't use. If I'd like to make minimal function of controller and views(index, new, show, delete). Do I need to code them all? Is there any good website that shows me how to do?? Thanks! – MKK Jun 20 '12 at 08:17
  • Yes, you need to write controller and views, but ones in the sample app are quite simple. If you unfamiliar with haml, try to convert it https://makandracards.com/makandra/544-convert-haml-to-erb – dimuch Jun 20 '12 at 08:54
  • Thanks a lot. I took a look at it. Haml looks kinda easy. another problem is, with this sample, you have to write receiver's actual email address into 'to' field. cant it be receiver's id instead? – MKK Jun 20 '12 at 09:23
3

Why are you trying to use ActionMailer? Are you sending emails or messages within the app? If you're just doing private messaging within the app, you should be able to create a PrivateMessage class:

class PrivateMessage
  has_one :sender, :class => 'User'
  has_one :recipient, :class => 'User'
end
Wade Tandy
  • 4,026
  • 3
  • 23
  • 31
  • Yes, I'd like it to deliver email by ActionMailer simulteneously. You mean making everything(Association, Controller, Model and view) from zero?? – MKK Jun 20 '12 at 05:31