Class: CMS::BaseController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/cms/base_controller.rb,
lib/generators/cms/templates/cms_base_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



29
30
31
32
33
34
35
# File 'app/controllers/cms/base_controller.rb', line 29

def create
  @record = subject.new(subject_params)
  @record.author = current_user if @record.respond_to?(:author=)
  @record.save
  set_element_variable
  respond_with @record
end

#destroyObject



50
51
52
53
# File 'app/controllers/cms/base_controller.rb', line 50

def destroy
  @record.destroy
  respond_with @record
end

#editObject



41
42
43
# File 'app/controllers/cms/base_controller.rb', line 41

def edit
  respond_with @record
end

#indexObject



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

def index
  @records = if params[:search].blank?
    subject.order('id asc')        .page(params[:page]).per(100)
  else
    subject.search(params[:search]).page(params[:page]).per(100)
  end

  set_collection_variable
  respond_with(@records)
end

#newObject



23
24
25
26
27
# File 'app/controllers/cms/base_controller.rb', line 23

def new
  @record = subject.new
  set_element_variable
  respond_with(@record)
end

#showObject



37
38
39
# File 'app/controllers/cms/base_controller.rb', line 37

def show
  respond_with @record
end

#updateObject



45
46
47
48
# File 'app/controllers/cms/base_controller.rb', line 45

def update
  @record.update_attributes subject_params
  respond_with @record
end