Class: BlocksController

Inherits:
ApplicationController show all
Defined in:
app/controllers/blocks_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/blocks_controller.rb', line 6

def create
  block = current_user.blocks.new(block_params)

  if block.save
    disconnect_if_contact(block.person)
    notice = {:notice => t('blocks.create.success')}
  else
    notice = {:error => t('blocks.create.failure')}
  end

  respond_with do |format|
    format.html{ redirect_to :back, notice }
    format.json{ render :nothing => true, :status => 204 }
  end
end

#destroyObject


22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/blocks_controller.rb', line 22

def destroy
  if current_user.blocks.find(params[:id]).delete
    notice = {:notice => t('blocks.destroy.success')}
  else
    notice = {:error => t('blocks.destroy.failure')}
  end

  respond_with do |format|
    format.html{ redirect_to :back, notice }
    format.json{ render :nothing => true, :status => 204 }
  end
end