Denshobato - Private messaging between models (PART 3)
Create messaging system between Reseller and Customer.
Denshobato Chat Panel Github Repository
Part 3
In PART 1 we built a basic app with reseller and customer models, devise authentication and index templates to list our models.
In PART 2 we did the most of our app, made users able to send messages to each other, create conversations, add conversations to trash and add other users to blacklist.
In Part 3 we’ll install an additional plugin to our conversation, which adds a chat panel.
We start with adding this gem to our Gemfile
run bundle install
Next, run generator
- Add
denshobato_chat_panel
method to your messagable models
- Copy this line to your
config/initializers/assets.rb
- In your
application.scss
import css
- In
layouts/application.erb
include javascript file in the bottom
- Mount API route in your
routes.rb
- On the page with your conversation (
show
action), e.glocalhost:3000/conversation/32
, add this helper with arguments
Now, your conversation page should look like this:
By default, your display name is the name of your model, your avatar is default gravatar image.
Let’s rewrite these methods.
We need to show full name of our Seller and Customer. We expect that your models have a first_name and last_name fields, same with image.
Now it looks better.
That’s all, thanks for reading.