Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rough howto #16

Closed
wolfgangihloff opened this issue Jan 18, 2012 · 6 comments
Closed

rough howto #16

wolfgangihloff opened this issue Jan 18, 2012 · 6 comments

Comments

@wolfgangihloff
Copy link

So I installed this gem and I know you are busy with other stuff, but maybe you can give me a 5 step simple howto, I seem to need to have a message model or something setup besides running the setup. I can deliver email or not?
A little bit more documentation is needed, I would then surely provide my project as a sample.
It just needs for me user, messages but even that simple documentation I cannot find.

@Roendal
Copy link
Member

Roendal commented Jan 18, 2012

Hi Wolfgang!

You need to run the install, migrate and modifiy a bit the initializer. You only need your "messageable" model, the one you want to be able to send and receive messages. Adding "act_as_messageale" is all you need.

I have improved the documentation in the README, https://github.com/ging/mailboxer/blob/master/README.textile. Please take a look at it and see if it helps you. If there is any problem, missunderstanding or something you miss, let me know to improve it before releasing a new version.

Good luck!

@wolfgangihloff
Copy link
Author

I feel I am too much a newbe, I would want to integrate this now in the rails UI, I assume my steps would need to be then:

alfa.send_message(beta, "Body", "subject")

create views to send message, thus have a message controller thus have a message model?

Adding this send message to my user object restful ressources sounds not so great or can I inherit something from that? might it be a nester route of my model already?

On Jan 18, 2012, at 10:12 PM, Eduardo Casanova wrote:

Hi Wolfgang!

You need to run the install, migrate and modifiy a bit the initializer. You only need your "messageable" model, the one you want to be able to send and receive messages. Adding "act_as_messageale" is all you need.

I have improved the documentation in the README, https://github.com/ging/mailboxer/blob/master/README.textile. Please take a look at it and see if it helps you. If there is any problem, missunderstanding or something you miss, let me know to improve it before releasing a new version.

Good luck!


Reply to this email directly or view it on GitHub:
#16 (comment)

@Roendal
Copy link
Member

Roendal commented Jan 19, 2012

Hi Wolfgang!

What mailboxer adds to you is a core for sending messages. Just by adding "act_as_messageable" to your User (or Whatever) model you get a lot of new methods added to it. For a full API you should refer to rubydoc. This core includes several models: Message, Conversation (a wrapper of messages), Receipt (relation model between the messageable and the message), Notification (related to notification system, not messaging system), Mailbox (managing the conversations, messages and receipt of a messageable) and Messageable (modeling the new methods added to your model "acting as messageable".

Those models already exist just by requiring mailboxer in your app, you don't need to have any message model. As you have infered, what you need to create are controllers and views.

I can't give you a more detailed documentation because each situation and application is different, but I can show you and example. Mailboxer was created as a part of SocialStream, a core to build social networks. As mailboxer is already integrated there, is a good start point to you. If you have serious problems understanding what goes now, please consider following some tutorials regarding rails 3.1, gems and engines, wich will surely be helpful.

The best way to do it ruby-like and restful is to create two controllers: ConversationsController and MessagesController

To add your routes in config/routes.rb (example):

Rails.application.routes.draw do
  #...
  resources :messages
  resources :conversations
  #...
end

Your ConversationsControllers should look like this.
Your MessagesControllers should look like this.

Please, notice that there are parts of the code not related with mailboxer, as the line

before_filter :authenticate_user!

related to the authentication protocol of SocialStream.

The views are heavily dependant on your application, so this will be the part you should work the most. The example of Conversations views are here and the ones for Messages are here. Please, take into account there are also javascript dependencies (in assets and in vendor) that you should look if you want to copy it exactly this way (wich I really don't recommend). The best way is to understand the views and make them your own way.

I hope that helps you. If so, let me know to add this short tutorial to the wiki or a more visible place than an issue.

Good luck.

@Roendal
Copy link
Member

Roendal commented Mar 4, 2012

Hi @wolfgangihloff!

Are you still interested in this issue?

@kcurtin
Copy link

kcurtin commented Mar 5, 2012

I just took a look and the info was definitely helpful - thanks for posting it. I'd suggest adding it to a wiki or linking to it in the README so that it's more visible. Looking forward to building this into my app - thanks for all of your work.

@Roendal
Copy link
Member

Roendal commented Mar 5, 2012

Thanks to you @kcurtin!

Working on it right now :)

@Roendal Roendal closed this as completed in 3cb2e39 Mar 5, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants