diff options
Diffstat (limited to 'app/controllers/system_messages_controller.rb')
-rw-r--r-- | app/controllers/system_messages_controller.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/controllers/system_messages_controller.rb b/app/controllers/system_messages_controller.rb new file mode 100644 index 0000000..d7fe515 --- /dev/null +++ b/app/controllers/system_messages_controller.rb @@ -0,0 +1,30 @@ +class SystemMessagesController < ApplicationController + load_and_authorize_resource :user + load_and_authorize_resource :system_message, :through => [:user] + + def index + @system_messages = @system_messages.where(:created_at => Time.now - 6.hours .. Time.now) + end + + def show + end + + def new + @system_message = @user.system_messages.build + end + + def create + @system_message = @user.system_messages.build(params[:system_message]) + if @system_message.save + # Push the new message via AJAX to the browser. + # + # PrivatePub.publish_to("/users/#{@system_message.user.id}/system_messages", + # "$('#system_message').empty();$('#system_message').append('<span class=\"created_at\">#{(I18n.l @system_message.created_at, :format => :short )}</span> #{@system_message.content}');$('#system_message_display').fadeIn();" + # ) + + redirect_to user_system_message_path(@user, @system_message), :notice => t('system_messages.controller.successfuly_created') + else + render :new + end + end +end |