Class: UnderConstructionEmailStorageController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/under_construction_email_storage_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
20
21
22
# File 'app/controllers/under_construction_email_storage_controller.rb', line 2

def create
  @email = UnderConstructionEmailStorage.new(params[:under_construction_email_storage])

  respond_to do |format|
    if @email.valid?
      @email.save_to_file
      @notice = I18n.t('controllers.under_construction_email_storage.create.flash.success', default: "Your email added successfully")
      format.html { redirect_to under_construction_index_path,
        notice: I18n.t('controllers.under_construction_email_storage.create.flash.success',
                default: "Your email added successfully"
        )}
      # TODO: UnderConstruction.config won't update if config file changes
      format.js { render template: "under_construction/#{UnderConstruction.config.theme}/create" }
    else
      @alert = @email.errors.full_messages[0]
      # TODO: UnderConstruction.config won't update if config file changes
      format.html { redirect_to under_construction_index_path, alert: @email.errors.full_messages }
      format.js { render template: "under_construction/#{UnderConstruction.config.theme}/create" }
    end
  end
end