Sha256: 64ce6ab6b6d0ebda1c78e92bf7348448f0bdd7a72ec636c8301ea562e70c21b4
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 KB
Contents
require_dependency "my_forum/application_controller" module MyForum class PrivateMessagesController < ApplicationController before_filter :only_for_registered_users def index @private_messages = PrivateMessage.inbox_for(current_user) render :inbox end def inbox end def outbox end def deleted end def new @pm = PrivateMessage.new @reply_pm = PrivateMessage.find(params[:reply_for_id]) if params[:reply_for_id] end def create @pm = PrivateMessage.new recipient = begin User.find_by_login(params[:private_message].delete(:recipient)) rescue #TODO send notification to admin nil end unless recipient @pm.errors.add(:base, t('.cant_find_recipient')) render :new return end @pm.recipient_id = recipient.id @pm.recipient_login = recipient.login @pm.sender_id = current_user_id @pm.sender_login = current_user.login @pm.assign_attributes(pm_params) @pm.save redirect_to action: :index end def show @pm = PrivateMessage.inbox_for(current_user).find(params[:id]) @pm.update!(unread: false) end private def pm_params params.require(:private_message).permit(:subject, :body) end def only_for_registered_users redirect_to root_path unless current_user end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
my_forum-0.0.1.beta2 | app/controllers/my_forum/private_messages_controller.rb |