Class: CMS::BaseController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- CMS::BaseController
- Defined in:
- app/controllers/cms/base_controller.rb,
lib/generators/cms/templates/cms_base_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/controllers/cms/base_controller.rb', line 29 def create @record = subject.new(subject_params) @record. = current_user if @record.respond_to?(:author=) @record.save set_element_variable respond_with @record end |
#destroy ⇒ Object
50 51 52 53 |
# File 'app/controllers/cms/base_controller.rb', line 50 def destroy @record.destroy respond_with @record end |
#edit ⇒ Object
41 42 43 |
# File 'app/controllers/cms/base_controller.rb', line 41 def edit respond_with @record end |
#index ⇒ Object
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 |
#new ⇒ Object
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 |
#show ⇒ Object
37 38 39 |
# File 'app/controllers/cms/base_controller.rb', line 37 def show respond_with @record end |
#update ⇒ Object
45 46 47 48 |
# File 'app/controllers/cms/base_controller.rb', line 45 def update @record.update_attributes subject_params respond_with @record end |