Archived
Made messages more thread-like (replies, editing, etc.)
This commit is contained in:
@@ -0,0 +1,77 @@
|
|||||||
|
class MessagerepliesController < ApplicationController
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@reply = Messagereply.find(params[:id])
|
||||||
|
if mod? || @reply.author.is?(current_user)
|
||||||
|
else
|
||||||
|
flash[:alert] = "You are not allowed to edit this reply"
|
||||||
|
redirect_to @reply.message
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
message = Message.find(params[:message_id])
|
||||||
|
if [message.user_sender, message.user_target].include? current_user
|
||||||
|
@reply = Messagereply.new(reply_params)
|
||||||
|
@reply.user_author = current_user
|
||||||
|
@reply.message = message
|
||||||
|
if @reply.save
|
||||||
|
@reply.message.update_attributes(user_hidden: nil)
|
||||||
|
if false
|
||||||
|
@reply.send_new_message_reply_mail
|
||||||
|
end
|
||||||
|
position = message.replies.count - 1
|
||||||
|
page = position / Kaminari.config.default_per_page + 1
|
||||||
|
redirect_to message_path(@reply.message, page: page) + "#reply-#{@reply.id}", notice: 'Reply created!'
|
||||||
|
else
|
||||||
|
flash[:alert] = "Could not create reply."
|
||||||
|
redirect_to Message.find(params[:message_id])
|
||||||
|
end
|
||||||
|
else
|
||||||
|
flash[:alert] = "You are not allowed to create replies."
|
||||||
|
redirect_to Message.find(params[:message_id])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@reply = Messagereply.find(params[:id])
|
||||||
|
if mod? || @reply.author.is?(current_user)
|
||||||
|
old_content = @reply.text_was
|
||||||
|
if @reply.update_attributes(reply_params)
|
||||||
|
if false
|
||||||
|
@reply.send_new_reply_mail(old_content)
|
||||||
|
end
|
||||||
|
flash[:notice] = "Reply updated!"
|
||||||
|
position = @reply.message.replies.index(@reply)
|
||||||
|
page = position / Kaminari.config.default_per_page + 1
|
||||||
|
redirect_to message_path(@reply.message, page: page) + "#reply-#{@reply.id}"
|
||||||
|
else
|
||||||
|
flash[:alert] = "There was a problem while updating your reply"
|
||||||
|
render action: "edit"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
flash[:alert] = "You are not allowed to edit this reply"
|
||||||
|
redirect_to @reply.message
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@reply = Messagereply.find(params[:id])
|
||||||
|
if mod? || @reply.author.is?(current_user)
|
||||||
|
if @reply.destroy
|
||||||
|
flash[:notice] = "Reply deleted!"
|
||||||
|
else
|
||||||
|
flash[:alert] = "There was a problem while deleting this reply"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
flash[:alert] = "You are not allowed to delete this reply"
|
||||||
|
end
|
||||||
|
redirect_to @reply.message
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def reply_params
|
||||||
|
params.require(:messagereply).permit(:text)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,16 +1,32 @@
|
|||||||
class MessagesController < ApplicationController
|
class MessagesController < ApplicationController
|
||||||
|
|
||||||
before_filter :check_permission, only: :destroy
|
before_filter :set_current
|
||||||
|
def set_current
|
||||||
|
User.current = current_user
|
||||||
|
end
|
||||||
|
|
||||||
|
before_filter :check_permission, only: [:show, :edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
if current_user
|
if current_user
|
||||||
@messages = Message.where(user_target: current_user).page(params[:page])
|
@messages = Message.where("(user_sender_id = ? OR user_target_id = ?) AND (user_hidden_id != ? OR user_hidden_id IS NULL)", current_user.id, current_user.id, current_user.id).page(params[:page])
|
||||||
else
|
else
|
||||||
flash[:alert] = "Please log in to see your private messages."
|
flash[:alert] = "Please log in to see your private messages."
|
||||||
redirect_to blogposts_path
|
redirect_to blogposts_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@replies = @message.replies.page(params[:page])
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
unless mod? || @message.author.is?(current_user)
|
||||||
|
flash[:alert] = "You are not allowed to edit this message!"
|
||||||
|
redirect_to @message
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
if current_user
|
if current_user
|
||||||
@message = Message.new
|
@message = Message.new
|
||||||
@@ -47,12 +63,32 @@ class MessagesController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
if mod? || @message.user_sender.is?(current_user)
|
||||||
|
@message.user_editor_id = current_user.id
|
||||||
|
@message.attributes = message_params
|
||||||
|
if @message.save
|
||||||
|
redirect_to @message, notice: 'Message has been updated.'
|
||||||
|
else
|
||||||
|
flash[:alert] = "There was a problem while updating the message."
|
||||||
|
render action: "edit"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
flash[:alert] = "You are not allowed to edit this message!"
|
||||||
|
redirect_to @message
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
if @message.user_target.is?(current_user)
|
if [@message.user_target, @message.user_sender].include?(current_user)
|
||||||
if @message.destroy
|
if @message.destroy
|
||||||
flash[:notice] = "Message deleted!"
|
flash[:notice] = "Message deleted!"
|
||||||
else
|
else
|
||||||
flash[:alert] = "There was a problem while deleting this message."
|
unless @message.user_hidden
|
||||||
|
flash[:alert] = "There was a problem while deleting this message."
|
||||||
|
else
|
||||||
|
Message.find(@message.id).update_attributes(user_hidden: current_user)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
flash[:alert] = "You are not allowed to delete this message."
|
flash[:alert] = "You are not allowed to delete this message."
|
||||||
@@ -73,15 +109,15 @@ class MessagesController < ApplicationController
|
|||||||
def message_params(add = [])
|
def message_params(add = [])
|
||||||
params[:message][:user_target_id] = User.find_by(ign: params[:message][:user_target].strip).try(:id)
|
params[:message][:user_target_id] = User.find_by(ign: params[:message][:user_target].strip).try(:id)
|
||||||
params[:message][:user_sender_id] = User.find_by(ign: params[:message][:user_sender]).id
|
params[:message][:user_sender_id] = User.find_by(ign: params[:message][:user_sender]).id
|
||||||
|
params[:message][:user_hidden_id] = User.find_by(ign: params[:message][:user_hidden]).try(:id)
|
||||||
params.require(:message).permit([:subject, :text, :user_target_id, :user_sender_id])
|
params.require(:message).permit([:subject, :text, :user_target_id, :user_sender_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def check_permission
|
def check_permission
|
||||||
@message = Message.find(params[:id])
|
@message = Message.find(params[:id])
|
||||||
unless @message.user_target == current_user
|
unless [@message.user_target, @message.user_sender].include? current_user
|
||||||
flash[:alert] = "You are not allowed to view this message"
|
flash[:alert] = "You are not allowed to view this message"
|
||||||
redirect_to home_statics_path
|
redirect_to home_statics_path
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,12 +4,34 @@ class Message < ActiveRecord::Base
|
|||||||
|
|
||||||
belongs_to :user_sender, class_name: "User", foreign_key: "user_sender_id"
|
belongs_to :user_sender, class_name: "User", foreign_key: "user_sender_id"
|
||||||
belongs_to :user_target, class_name: "User", foreign_key: "user_target_id"
|
belongs_to :user_target, class_name: "User", foreign_key: "user_target_id"
|
||||||
|
belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id"
|
||||||
|
belongs_to :user_hidden, class_name: "User", foreign_key: "user_hidden_id"
|
||||||
|
|
||||||
|
|
||||||
validates_presence_of :user_sender, :user_target, :text, :subject
|
validates_presence_of :user_sender, :user_target, :text, :subject
|
||||||
|
|
||||||
validates_length_of :text, in: 1..8000
|
validates_length_of :text, in: 1..8000
|
||||||
validates_length_of :subject, in: 1..2000
|
validates_length_of :subject, in: 1..2000
|
||||||
|
|
||||||
|
has_many :messagereplies
|
||||||
|
|
||||||
|
accepts_nested_attributes_for :messagereplies
|
||||||
|
|
||||||
|
before_destroy :do_destroy?
|
||||||
|
|
||||||
|
def do_destroy?
|
||||||
|
unless user_hidden || user_sender == user_target
|
||||||
|
update_attributes(user_hidden: User.current)
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
subject
|
||||||
|
end
|
||||||
|
|
||||||
def sender
|
def sender
|
||||||
@sender ||= if self.user_sender.present?
|
@sender ||= if self.user_sender.present?
|
||||||
user_sender
|
user_sender
|
||||||
@@ -26,6 +48,18 @@ class Message < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def editor
|
||||||
|
@editor ||= (self.user_editor || User.first)
|
||||||
|
end
|
||||||
|
|
||||||
|
def edited?
|
||||||
|
!!user_editor_id
|
||||||
|
end
|
||||||
|
|
||||||
|
def replies
|
||||||
|
messagereplies
|
||||||
|
end
|
||||||
|
|
||||||
def send_new_message_mail
|
def send_new_message_mail
|
||||||
begin
|
begin
|
||||||
mail = RedstonerMailer.new_message_mail(user_target, self)
|
mail = RedstonerMailer.new_message_mail(user_target, self)
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
class Messagereply < ActiveRecord::Base
|
||||||
|
|
||||||
|
include MailerHelper
|
||||||
|
include UsersHelper
|
||||||
|
|
||||||
|
belongs_to :message
|
||||||
|
belongs_to :user_author, class_name: "User", foreign_key: "user_author_id"
|
||||||
|
belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
validates_presence_of :text
|
||||||
|
validates_length_of :text, in: 1..8000
|
||||||
|
|
||||||
|
def get_message
|
||||||
|
message
|
||||||
|
end
|
||||||
|
|
||||||
|
def author
|
||||||
|
@author ||= if self.user_author.present?
|
||||||
|
user_author
|
||||||
|
else
|
||||||
|
User.first
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def editor
|
||||||
|
# can be nil
|
||||||
|
@editor ||= user_editor
|
||||||
|
end
|
||||||
|
|
||||||
|
def edited?
|
||||||
|
!!user_editor_id
|
||||||
|
end
|
||||||
|
|
||||||
|
def send_new_reply_mail(old_content = "")
|
||||||
|
users = mentions(content) - mentions(old_content)
|
||||||
|
|
||||||
|
# thread + replies
|
||||||
|
posts = message.replies.to_a
|
||||||
|
posts << message if message.author.mail_own_message_reply?
|
||||||
|
# only send "reply" mail when reply is new
|
||||||
|
unless old_content.present?
|
||||||
|
posts.each do |post|
|
||||||
|
# don't send mail to the author of this reply, don't send to banned/disabled users
|
||||||
|
if post.author != author && post.author.normal? && post.author.confirmed? # &&
|
||||||
|
users << post.author if post.author.mail_other_thread_reply?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# making sure we don't send multiple mails to the same user
|
||||||
|
users.uniq!
|
||||||
|
|
||||||
|
mails = []
|
||||||
|
users.each do |usr|
|
||||||
|
begin
|
||||||
|
mails << RedstonerMailer.new_thread_reply_mail(usr, self)
|
||||||
|
rescue => e
|
||||||
|
Rails.logger.error "---"
|
||||||
|
Rails.logger.error "WARNING: Failed to create new_thread_reply_mail (view) for reply#: #{@self.id}, user: #{@user.name}, #{@user.email}"
|
||||||
|
Rails.logger.error e.message
|
||||||
|
Rails.logger.error "---"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
background_mailer(mails)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -24,6 +24,8 @@ class User < ActiveRecord::Base
|
|||||||
has_many :blogposts
|
has_many :blogposts
|
||||||
has_many :comments
|
has_many :comments
|
||||||
|
|
||||||
|
cattr_accessor :current
|
||||||
|
|
||||||
# foo.bar.is?(current_user)
|
# foo.bar.is?(current_user)
|
||||||
def is? (user)
|
def is? (user)
|
||||||
self == user
|
self == user
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<%= form_for [reply.get_message, reply] do |f| %>
|
||||||
|
<%= render partial: "md_editor", locals: {name: "messagereply[text]", content: reply.text} %>
|
||||||
|
<p><%= f.submit "Reply", class: "btn blue" %></p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<div class="item-group thread-reply with-avatar" id="reply-<%= reply.id %>">
|
||||||
|
<div class="header">
|
||||||
|
<%= link_to(reply.author.avatar(64), reply.author, title: reply.author.ign) %>
|
||||||
|
<%= render partial: "users/username", locals: { user: reply.author } %>
|
||||||
|
<%= link_to "#reply-#{reply.id}" do %>
|
||||||
|
<%= ago reply.created_at %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= link_to "edit", edit_message_messagereply_path(reply.message, reply), class: "editlink" if mod? || reply.author.is?(current_user) %>
|
||||||
|
<div class="clear-right"></div>
|
||||||
|
</div>
|
||||||
|
<div class="items">
|
||||||
|
<div class="item content">
|
||||||
|
<%= render_md(reply.text).html_safe %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<% title "Edit Message Reply: #{@reply.message.subject}" %>
|
||||||
|
|
||||||
|
<%
|
||||||
|
position = @reply.message.replies.index(@reply)
|
||||||
|
page = position / Kaminari.config.default_per_page + 1
|
||||||
|
%>
|
||||||
|
|
||||||
|
<%= link_to "Messages", messages_path %> → <%= link_to @reply.message, message_path(@reply.message, page: page) + "#reply-#{@reply.id}" %> → Edit reply
|
||||||
|
<h1>Edit reply</h1>
|
||||||
|
<%= form_for [@reply.message, @reply] do |f| %>
|
||||||
|
<%= render partial: "md_editor", locals: {name: "messagereply[text]", content: @reply.text} %>
|
||||||
|
<p><%= f.submit "Reply", class: "btn blue left" %></p>
|
||||||
|
<% end %>
|
||||||
|
<p><%= button_to "Delete reply", [@reply.message, @reply], method: "delete", data: {confirm: "Delete reply forever?"}, class: "btn red right" %></p>
|
||||||
|
<div class="clear"></div>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<% title "Edit Thread: #{@message}" %>
|
||||||
|
|
||||||
|
<h1>Edit thread</h1>
|
||||||
|
<%= link_to "Messages", messages_path %> → <%= link_to @message, @message %> → Edit Message
|
||||||
|
<%= form_for @message do |f|%>
|
||||||
|
<div class="table-cell full-width">
|
||||||
|
<%= f.text_field :subject, placeholder: "Subject" %>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<%= render partial: "md_editor", locals: {name: "message[text]", content: @message.text} %>
|
||||||
|
<p><%= f.submit "Update message", class: "btn blue left" %></p>
|
||||||
|
<%= f.hidden_field :user_sender, value: @message.user_sender %>
|
||||||
|
<%= f.hidden_field :user_target, value: @message.user_target %>
|
||||||
|
<% end %>
|
||||||
|
<%= button_to "Delete ", @message, :method => "delete", data: {confirm: "Delete message & comments forever?"}, class: "btn red right" %>
|
||||||
|
<div class="clear"></div>
|
||||||
|
|
||||||
@@ -15,13 +15,21 @@
|
|||||||
<% @messages.each do |message| %>
|
<% @messages.each do |message| %>
|
||||||
<div class="item-group with-avatar">
|
<div class="item-group with-avatar">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<%= link_to(message.user_sender.avatar(64), message.user_sender, title: message.user_sender.ign) %>
|
<%
|
||||||
<%= render partial: "users/username", locals: { user: message.user_sender } %>
|
if current_user == message.user_sender
|
||||||
<%= ago message.created_at %>
|
user = message.user_target
|
||||||
<span style="font-size:18px">
|
else
|
||||||
|
user = message.user_sender
|
||||||
|
end
|
||||||
|
%>
|
||||||
|
<%= link_to(user.avatar(64), user, title: user.ign) %>
|
||||||
|
<%= render partial: "users/username", locals: { user: user } %>
|
||||||
|
<span style="font-size:16px">
|
||||||
|
|
||||||
|
<b><%= link_to message.subject, message %></b>
|
||||||
|
|
|
|
||||||
<b><%= link_to message.subject, messages_path %></b>
|
|
||||||
</span>
|
</span>
|
||||||
|
<%= ago message.created_at %>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<%= link_to "Delete message", message, :method => "delete", class: "editlink", data: {confirm: "Delete this message forever?"} %>
|
<%= link_to "Delete message", message, :method => "delete", class: "editlink", data: {confirm: "Delete this message forever?"} %>
|
||||||
</div>
|
</div>
|
||||||
@@ -29,7 +37,21 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="items">
|
<div class="items">
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<%= render_md(truncate message.text, length: 20, omission: "...").html_safe %>
|
<%= truncate message.text, length: 20, omission: "..." %>
|
||||||
|
<div class="item-info items bold">
|
||||||
|
<% if rpl = message.replies.last %>
|
||||||
|
<%= rpl.author.name %>
|
||||||
|
<%
|
||||||
|
position = message.replies.count - 1
|
||||||
|
page = position / Kaminari.config.default_per_page + 1
|
||||||
|
%>
|
||||||
|
<%= link_to "replied", message_path(message, page: page) + "#reply-#{rpl.id}" %>
|
||||||
|
<%= ago rpl.created_at %>.
|
||||||
|
<% else %>
|
||||||
|
No replies yet.
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<%= link_to "Messages", messages_path %>
|
||||||
|
<h1><%= title @message.subject %></h1>
|
||||||
|
<div class="item-group thread with-avatar" id="message-<%= @message.id %>">
|
||||||
|
<div class="header">
|
||||||
|
<%= link_to(@message.sender.avatar(64), @message.sender, title: @message.sender.ign) %>
|
||||||
|
<%= render partial: "users/username", locals: { user: @message.sender } %>
|
||||||
|
<%= link_to p do %>
|
||||||
|
<%= ago @message.created_at %>
|
||||||
|
<% end %>
|
||||||
|
<%= link_to "edit", edit_message_path(@message), class: "editlink" if mod? || @message.sender.is?(current_user) %>
|
||||||
|
<div class="clear-right"></div>
|
||||||
|
</div>
|
||||||
|
<div class="items">
|
||||||
|
<% if @message.edited? %>
|
||||||
|
<div class="item edited">
|
||||||
|
Last edited <%= ago @message.updated_at %> by <%= link_to @message.editor.name, @message.editor %>.
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<div class="item content">
|
||||||
|
<%= render_md(@message.text).html_safe %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="replies">
|
||||||
|
<h3><%= "#{pluralize(@message.replies.size, 'reply')}." %></h3>
|
||||||
|
<% @replies.each do |reply| %>
|
||||||
|
<%= render partial: "messagereplies/reply", locals: {reply: reply} %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= paginate @replies %>
|
||||||
|
|
||||||
|
<%= render partial: "messagereplies/new", locals: {reply: Messagereply.new(message: @message)} %>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
<%= link_to "edit profile", edit_user_path(@user), :class => "btn blue" %>
|
<%= link_to "edit profile", edit_user_path(@user), :class => "btn blue" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @user.is?(current_user) %>
|
<% if @user.is?(current_user) %>
|
||||||
<%= link_to "Private Messages (#{Message.where(user_target: current_user).count})", messages_path, :class => "btn blue" %>
|
<%= link_to "Private Messages (#{Message.where("user_sender_id = ? OR user_target_id = ?", current_user.id, current_user.id).count})", messages_path, :class => "btn blue" %>
|
||||||
<% else %>
|
<% elsif current_user %>
|
||||||
<%= link_to "Send this user a message", new_message_path(user_target: @user.ign), :class => "btn blue" %>
|
<%= link_to "Send this user a message", new_message_path(user_target: @user.ign), :class => "btn blue" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ Redstoner::Application.routes.draw do
|
|||||||
end
|
end
|
||||||
|
|
||||||
resources :messages do
|
resources :messages do
|
||||||
|
resources :messagereplies, path: 'replies'
|
||||||
collection do
|
collection do
|
||||||
post 'destroy_all'
|
post 'destroy_all'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
class CreateMessages < ActiveRecord::Migration
|
class CreateMessages < ActiveRecord::Migration
|
||||||
def change
|
def change
|
||||||
create_table :messages do |t|
|
create_table :messages do |t|
|
||||||
|
|
||||||
t.text :message
|
t.text :message
|
||||||
t.references :user_sender
|
t.references :user_sender
|
||||||
t.references :user_target
|
t.references :user_target
|
||||||
|
t.references :user_editor
|
||||||
|
t.references :user_hidden
|
||||||
t.datetime :created_at
|
t.datetime :created_at
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
class CreateMessagereplies < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :messagereplies do |t|
|
||||||
|
t.text :text
|
||||||
|
|
||||||
|
t.references :user_author
|
||||||
|
t.references :user_editor
|
||||||
|
t.references :message
|
||||||
|
|
||||||
|
t.timestamps null: true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class AddUserEditorToMessages < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_reference :messages, :user_editor
|
||||||
|
end
|
||||||
|
end
|
||||||
+14
-1
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20170525184355) do
|
ActiveRecord::Schema.define(version: 20170613144233) do
|
||||||
|
|
||||||
create_table "blogposts", force: :cascade do |t|
|
create_table "blogposts", force: :cascade do |t|
|
||||||
t.string "title", limit: 191
|
t.string "title", limit: 191
|
||||||
@@ -76,11 +76,24 @@ ActiveRecord::Schema.define(version: 20170525184355) do
|
|||||||
t.string "color", limit: 191
|
t.string "color", limit: 191
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "messagereplies", force: :cascade do |t|
|
||||||
|
t.text "text", limit: 65535
|
||||||
|
t.integer "user_author_id", limit: 4
|
||||||
|
t.integer "user_editor_id", limit: 4
|
||||||
|
t.integer "message_id", limit: 4
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "messages", force: :cascade do |t|
|
create_table "messages", force: :cascade do |t|
|
||||||
t.text "text", limit: 65535
|
t.text "text", limit: 65535
|
||||||
t.integer "user_sender_id", limit: 4
|
t.integer "user_sender_id", limit: 4
|
||||||
t.integer "user_target_id", limit: 4
|
t.integer "user_target_id", limit: 4
|
||||||
|
t.integer "user_hidden_id", limit: 4
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
t.string "subject", limit: 191
|
||||||
|
t.integer "user_editor_id", limit: 4
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "register_tokens", force: :cascade do |t|
|
create_table "register_tokens", force: :cascade do |t|
|
||||||
|
|||||||
+2
-1
@@ -61,5 +61,6 @@ Message.create!(
|
|||||||
user_sender_id: 2,
|
user_sender_id: 2,
|
||||||
user_target_id: 2,
|
user_target_id: 2,
|
||||||
text: "This is a very long message that I will be using to test a plentitude of things. :)",
|
text: "This is a very long message that I will be using to test a plentitude of things. :)",
|
||||||
created_at: Time.utc(0).to_datetime
|
created_at: Time.utc(0).to_datetime,
|
||||||
|
subject: "Hello there!"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user