2009-01-06 11:49:19 +01:00
|
|
|
class MessagesController < ApplicationController
|
2011-05-18 14:47:17 +02:00
|
|
|
|
2009-01-06 11:49:19 +01:00
|
|
|
# Renders the "inbox" action.
|
|
|
|
def index
|
2009-03-23 11:31:36 +01:00
|
|
|
@messages = Message.public.paginate :page => params[:page], :per_page => 20, :order => 'created_at DESC'
|
2009-01-06 11:49:19 +01:00
|
|
|
end
|
2011-05-18 14:47:17 +02:00
|
|
|
|
2009-01-06 11:49:19 +01:00
|
|
|
# Creates a new message object.
|
|
|
|
def new
|
2011-05-18 14:47:17 +02:00
|
|
|
@message = Message.new(params[:message])
|
2009-01-06 11:49:19 +01:00
|
|
|
end
|
2011-05-18 14:47:17 +02:00
|
|
|
|
2009-01-06 11:49:19 +01:00
|
|
|
# Creates a new message.
|
|
|
|
def create
|
2009-01-15 18:26:37 +01:00
|
|
|
@message = @current_user.send_messages.new(params[:message])
|
|
|
|
if @message.save
|
2009-03-09 13:02:43 +01:00
|
|
|
#FIXME: Send Mails wit ID instead of using message.state ...
|
|
|
|
call_rake :send_emails
|
2011-05-18 14:47:17 +02:00
|
|
|
redirect_to messages_url, :notice => "Nachricht ist gespeichert und wird versendet."
|
2009-01-06 11:49:19 +01:00
|
|
|
else
|
|
|
|
render :action => 'new'
|
|
|
|
end
|
|
|
|
end
|
2011-05-18 14:47:17 +02:00
|
|
|
|
2009-01-06 11:49:19 +01:00
|
|
|
# Shows a single message.
|
|
|
|
def show
|
2009-01-15 18:26:37 +01:00
|
|
|
@message = Message.find(params[:id])
|
2009-01-06 11:49:19 +01:00
|
|
|
end
|
|
|
|
end
|