Class: Cms::AssetsController

Inherits:
MainController show all
Defined in:
app/controllers/cms/assets_controller.rb

Instance Method Summary collapse

Methods inherited from MainController

#index

Methods included from RoleAuthentication

#authenticate_user

Methods inherited from SetupController

#authorize_role, #current_user

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/cms/assets_controller.rb', line 12

def create
  @asset = @context.assets.build
  @asset.assign_ordered_attributes params[:cms_asset]

  if @asset.save
    flash[:notice] = t('assets.flash.created')
    redirect_to cms_root_path
  else
    render :action => 'new'
  end
end

#destroyObject



51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/cms/assets_controller.rb', line 51

def destroy
  @asset = @context.assets.find(params[:id])
  @asset.destroy

  flash[:notice] = t('assets.flash.deleted')

  respond_to do |format|
    format.html { redirect_to cms_root_path }
  end
end

#editObject



24
25
26
# File 'app/controllers/cms/assets_controller.rb', line 24

def edit
  @asset = @context.assets.find params[:id]
end

#newObject



8
9
10
# File 'app/controllers/cms/assets_controller.rb', line 8

def new
  @asset = create_tagged_asset
end

#showObject



4
5
6
# File 'app/controllers/cms/assets_controller.rb', line 4

def show
  @asset = @context.assets.find params[:id]
end

#updateObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/cms/assets_controller.rb', line 28

def update
  @asset = @context.assets.find params[:id]
  @asset.assign_ordered_attributes params[:cms_asset]

  if @asset.save
    respond_to do |format|
      format.html {
        redirect_to edit_cms_asset_path(@asset), :notice => t('assets.flash.updated')
      }
      format.js {
        flash.now[:notice] = t('assets.flash.updated')
      }
    end
  else
    respond_to do |format|
      format.html {
        render :action => 'edit'
      }
      format.js
    end
  end
end