Class: Virgo::Admin::ColumnsController

Inherits:
BaseController show all
Defined in:
app/controllers/virgo/admin/columns_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#authorize_admin_user, #search, #set_is_admin_view

Methods included from RenderHelper

#render_content, #with_format

Methods included from Virgo::ApplicationHelper

#action?, #admin?, #admin_access?, #admin_view?, #alerts, #base_errors, #category_timestamp, #column_timestamp, #compact_html, #controller?, #decode_html_entities, #expanded_post_url, #is_admin_view?, #page_url, #post_time_format, #post_timestamp, #production?, #redis_timestamp_key_for, #site, #site_key, #superuser?, #tabbed_param, #word_count

Instance Method Details

#createObject



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

def create
  @column = Column.new(column_params)

  authorize! :create, @column

  if @column.save
    flash[:notice] = "Column created"
    redirect_to admin_columns_path
  else
    render :new
  end
end

#destroyObject



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

def destroy
  @column.destroy

  flash[:notice] = "Column removed"

  redirect_to admin_columns_path
end

#editObject



33
34
# File 'app/controllers/virgo/admin/columns_controller.rb', line 33

def edit
end

#indexObject



7
8
9
10
11
12
13
14
# File 'app/controllers/virgo/admin/columns_controller.rb', line 7

def index
  if params[:sort].nil?
    flash.keep
    redirect_to admin_columns_path(sort: 'weight') and return
  end

  @columns = Column.order(sort_order).with_post_count.page(params[:page])
end

#newObject



16
17
18
# File 'app/controllers/virgo/admin/columns_controller.rb', line 16

def new
  @column = Column.new
end

#updateObject



36
37
38
39
40
41
42
43
# File 'app/controllers/virgo/admin/columns_controller.rb', line 36

def update
  if @column.update(column_params)
    flash[:notice] = "Column settings updated"
    redirect_to admin_columns_path
  else
    render :edit
  end
end