summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornfoy <nfoy@purdue.edu>2014-04-22 22:43:59 -0400
committernfoy <nfoy@purdue.edu>2014-04-22 22:43:59 -0400
commitd53c2b7971388026be5c42cd833f7e16781f2c18 (patch)
tree90e5946dc5dbdad4cc60d954e1c6642cc3c64d16
parentfede678430be34f854bcf7e39c29d5e5ecea929b (diff)
Figured out mailboxer for sending pms and updated individual message view.
-rw-r--r--app/controllers/pms_controller.rb4
-rw-r--r--app/models/pm.rb14
-rw-r--r--app/models/user.rb8
-rw-r--r--app/views/alerts/show.html.erb2
-rw-r--r--app/views/layouts/application.html.erb1
-rw-r--r--app/views/pms/_form.html.erb4
-rw-r--r--app/views/pms/index.html.erb4
-rw-r--r--app/views/pms/show.html.erb4
8 files changed, 30 insertions, 11 deletions
diff --git a/app/controllers/pms_controller.rb b/app/controllers/pms_controller.rb
index af112d1..1279fdf 100644
--- a/app/controllers/pms_controller.rb
+++ b/app/controllers/pms_controller.rb
@@ -23,6 +23,10 @@ class PmsController < ApplicationController
# POST /pms.json
def create
@pm = Pm.new(pm_params)
+ @pm.author = current_user
+ require 'pp'
+ pp pm_params['recipient_id']
+ @pm.recipient = User.find_by_user_name(pm_params['recipient_id'])
respond_to do |format|
if @pm.save
diff --git a/app/models/pm.rb b/app/models/pm.rb
index 9fce2b3..3ebb69d 100644
--- a/app/models/pm.rb
+++ b/app/models/pm.rb
@@ -1,4 +1,14 @@
class Pm < ActiveRecord::Base
- belongs_to :author
- belongs_to :recipient
+ belongs_to :author, class_name: "User"
+ belongs_to :recipient, class_name: "User"
+
+ def name
+ return current_user.name
+ end
+
+=begin
+ def mailboxer_email(email)
+ return current_user.email
+ end
+=end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index aacd7b1..6118e2a 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -12,6 +12,14 @@ class User < ActiveRecord::Base
acts_as_messageable
+ def name
+ return current_user.user_name
+ end
+
+ def mailboxer_email(object)
+ return nil
+ end
+
before_save { self.email = email.downcase }
before_save { self.user_name = user_name }
diff --git a/app/views/alerts/show.html.erb b/app/views/alerts/show.html.erb
index 5dda2c9..59d8094 100644
--- a/app/views/alerts/show.html.erb
+++ b/app/views/alerts/show.html.erb
@@ -1,6 +1,6 @@
<p>
<strong>Author:</strong>
- <%= @alert.author %>
+ <%# @alert.author %>
</p>
<p>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index fb5c1c5..eca33b8 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -30,6 +30,7 @@
<div id="log-buttons">
<% if signed_in? %>
<%= link_to current_user.user_name, current_user, :class => "user" %>
+ <%= link_to "Messages", pms_path %>
<%= link_to "Sign out", session_path("current"), method: "delete", :class => "signout" %>
<% if current_user.can? :edit_server %>
<%= link_to "Server settings", edit_server_path, :class => "server" %>
diff --git a/app/views/pms/_form.html.erb b/app/views/pms/_form.html.erb
index 480e308..e9a7c08 100644
--- a/app/views/pms/_form.html.erb
+++ b/app/views/pms/_form.html.erb
@@ -12,10 +12,6 @@
<% end %>
<div class="field">
- <%= f.label :author_id %><br>
- <%= f.text_field :author_id %>
- </div>
- <div class="field">
<%= f.label :recipient_id %><br>
<%= f.text_field :recipient_id %>
</div>
diff --git a/app/views/pms/index.html.erb b/app/views/pms/index.html.erb
index cb7fe4b..f5dfe02 100644
--- a/app/views/pms/index.html.erb
+++ b/app/views/pms/index.html.erb
@@ -15,8 +15,8 @@
<tbody>
<% @pms.each do |pm| %>
<tr>
- <td><%= pm.author %></td>
- <td><%= pm.recipient %></td>
+ <td><%= pm.author.user_name %></td>
+ <td><%= pm.recipient.user_name %></td>
<td><%= pm.message %></td>
<td><%= link_to 'Show', pm %></td>
<td><%= link_to 'Edit', edit_pm_path(pm) %></td>
diff --git a/app/views/pms/show.html.erb b/app/views/pms/show.html.erb
index 2a03716..595afce 100644
--- a/app/views/pms/show.html.erb
+++ b/app/views/pms/show.html.erb
@@ -1,11 +1,11 @@
<p>
<strong>Author:</strong>
- <%= @pm.author %>
+ <%= @pm.author.user_name %>
</p>
<p>
<strong>Recipient:</strong>
- <%= @pm.recipient %>
+ <%= @pm.recipient.user_name %>
</p>
<p>