-
Notifications
You must be signed in to change notification settings - Fork 58
Example controller
LTe edited this page Aug 17, 2012
·
5 revisions
class UsersController < ApplicationController
def index
@messages = current_user.received_messages
end
def outbox
@messages = current_user.sent_messages
end
def show
@message = current_user.messages.find(params[:id])
end
def destroy
@message = current_user.messages.find(params[:id])
if @message.destroy
flash[:notice] = "All ok"
else
flash[:error] = "Fail"
end
end
def new
@message = ActsAsMessageable::Message.new
end
def create
@to = User.find_by_email(params[:message][:to])
current_user.send_message(@to, params[:message][:topic], params[:message][:body])
end
end