foodsoft/app/controllers/messages_controller.rb

29 lines
728 B
Ruby
Raw Normal View History

2009-01-06 11:49:19 +01:00
class MessagesController < ApplicationController
2009-01-06 11:49:19 +01:00
# Renders the "inbox" action.
def index
@messages = Message.public.paginate :page => params[:page], :per_page => 20, :order => 'created_at DESC'
2009-01-06 11:49:19 +01:00
end
2009-01-06 11:49:19 +01:00
# Creates a new message object.
def new
@message = Message.new(params[:message])
2009-01-06 11:49:19 +01:00
end
2009-01-06 11:49:19 +01:00
# Creates a new message.
def create
@message = @current_user.send_messages.new(params[:message])
if @message.save
@message.deliver #TODO: Put this into a background job
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
2009-01-06 11:49:19 +01:00
# Shows a single message.
def show
@message = Message.find(params[:id])
2009-01-06 11:49:19 +01:00
end
end