foodsoft/app/controllers/messages_controller.rb

29 lines
690 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.page(params[:page]).per(@per_page).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.delay.deliver(@message.id)
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