Class: SitesController

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

Instance Method Summary collapse

Methods included from Zena::App

included

Instance Method Details

#actionObject



48
49
50
51
52
53
54
55
# File 'app/controllers/sites_controller.rb', line 48

def action
  if Site::ACTIONS.include?(params[:do])
    @site.send(params[:do])
    flash.now[:notice] = _("#{params[:do]} done.")
  else
    flash.now[:error] = _("Invalid action '%{action}'.") % {:action => params[:do]}
  end
end

#editObject



26
27
28
29
30
31
# File 'app/controllers/sites_controller.rb', line 26

def edit
  respond_to do |format|
    format.html
    format.js   { render :partial => 'sites/form', :layout => false }
  end
end

#indexObject



8
9
10
11
12
13
14
15
16
# File 'app/controllers/sites_controller.rb', line 8

def index
  secure!(Site) do
    @sites = Site.paginate(:all, :order => 'host', :per_page => 20, :page => params[:page])
  end
  respond_to do |format|
    format.html # index.erb
    format.xml  { render :xml => @sites }
  end
end

#showObject



18
19
20
21
22
23
24
# File 'app/controllers/sites_controller.rb', line 18

def show
  respond_to do |format|
    format.html
    format.xml  { render :xml => @site }
    format.js
  end
end

#updateObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/sites_controller.rb', line 33

def update
  respond_to do |format|
    if @site.update_attributes(params[:site])
      flash.now[:notice] = _('Site was successfully updated.')
      format.html { redirect_to site_path(@site) }
      format.js
      format.xml  { head :ok }
    else
      format.html { render :action => "edit" }
      format.js
      format.xml  { render :xml => @site.errors }
    end
  end
end