flash[:error] = t "message.new.limit_exceeded"
else
@message = Message.new(message_params)
- @message.to_user_id = @this_user.id
- @message.from_user_id = current_user.id
+ @message.recipient = @this_user
+ @message.sender = current_user
@message.sent_on = Time.now.getutc
if @message.save
def reply
message = Message.find(params[:message_id])
- if message.to_user_id == current_user.id
+ if message.recipient == current_user
message.update(:message_read => true)
@message = Message.new(
@title = t "message.read.title"
@message = Message.find(params[:message_id])
- if @message.to_user_id == current_user.id || @message.from_user_id == current_user.id
- @message.message_read = true if @message.to_user_id == current_user.id
+ if @message.recipient == current_user || @message.sender == current_user
+ @message.message_read = true if @message.recipient == current_user
@message.save
else
flash[:notice] = t "message.read.wrong_user", :user => current_user.display_name