Class: Dust::BlocksController

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

Instance Method Summary collapse

Methods inherited from AuthenticationController

#not_authenticated, #permission_denied, #try_return_to_previous_page

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
# File 'app/controllers/dust/blocks_controller.rb', line 17

def create
  @block = Dust::Block.new(params[:dust_block])
  if @block.save
    flash[:notice] = "Successfully created block."
    try_return_to_previous_page(dust_blocks_url)
  else
    render :action => 'new'
  end
end

#destroyObject



41
42
43
44
45
46
# File 'app/controllers/dust/blocks_controller.rb', line 41

def destroy
  @block = Dust::Block.find(params[:id])
  @block.destroy
  flash[:notice] = "Successfully destroyed block."
  try_return_to_previous_page(dust_blocks_url)
end

#editObject



27
28
29
# File 'app/controllers/dust/blocks_controller.rb', line 27

def edit
  @block = Dust::Block.find(params[:id])
end

#indexObject



8
9
10
# File 'app/controllers/dust/blocks_controller.rb', line 8

def index
  @blocks = Dust::Block.page(params[:search], params[:page]) 
end

#newObject



12
13
14
15
# File 'app/controllers/dust/blocks_controller.rb', line 12

def new
  @block = Dust::Block.new(:show => params[:show]) if params[:show]
  @block ||= Dust::Block.new
end

#updateObject



31
32
33
34
35
36
37
38
39
# File 'app/controllers/dust/blocks_controller.rb', line 31

def update
  @block = Dust::Block.find(params[:id])
  if @block.update_attributes(params[:dust_block])
    flash[:notice] = "Successfully updated block."
    try_return_to_previous_page(dust_blocks_path)
  else
    render :action => 'edit'
  end
end