Class: FeedbackPopup::MessagesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/feedback_popup/messages_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/feedback_popup/messages_controller.rb', line 2

def create
  message = FeedbackPopup::Message.new(message_params)
  if message.deliver
    @success_message = t('feedback_popup.message_sent')
  else
    @error_message = message.errors.full_messages.join("; ")
  end
  respond_to do |format|
    format.html {
      flash[:notice] = @success_message if @success_message
      flash[:alert] = @error_message if @error_message
      redirect_to root_url
    }
    format.js {
      render :layout => nil
    }
  end
end