Class: Admin::SitesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/sites_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/admin/sites_controller.rb', line 19

def create
  site = Site.new params[:site]
  section = site.sections.build(params[:section])
  site.sections << section

  if site.save
    redirect_to admin_site_url(site), notice: "The site has been created."
  else
    flash.now.alert = "The site could not be created"
    render action: :new
  end
end

#destroyObject



44
45
46
47
48
49
50
51
# File 'app/controllers/admin/sites_controller.rb', line 44

def destroy
  if @site.destroy
    redirect_to return_from(:site_deleted), notice: "The site has been deleted."
  else
    flash.now.alert = "The site could not be deleted"
    render action: :show
  end
end

#editObject



32
33
# File 'app/controllers/admin/sites_controller.rb', line 32

def edit
end

#indexObject



6
7
8
# File 'app/controllers/admin/sites_controller.rb', line 6

def index
  @sites = Site.paginate(:page => params[:page], :per_page => params[:per_page]).order(:id)
end

#newObject



16
17
# File 'app/controllers/admin/sites_controller.rb', line 16

def new
end

#showObject



10
11
12
13
14
# File 'app/controllers/admin/sites_controller.rb', line 10

def show
  @users = @site.users
  @contents = @site.unapproved_comments.group_by(&:commentable) if @site.respond_to?(:unapproved_comments)
  @activities = @site.grouped_activities
end

#updateObject



35
36
37
38
39
40
41
42
# File 'app/controllers/admin/sites_controller.rb', line 35

def update
  if @site.update params[:site]
    redirect_to edit_admin_site_url, notice: "The site has been updated."
  else
    flash.now.alert = "The site could not be updated"
    render action: :edit
  end
end