Class: BaseController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- BaseController
- Defined in:
- app/controllers/base_controller.rb
Constant Summary collapse
- PER_PAGE =
6
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #template_not_found ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
32 33 34 35 36 |
# File 'app/controllers/base_controller.rb', line 32 def create instance_variable_set(instance_variable, model.new(permit_params)) flash[:success] = I18n.t('created', model: model.model_name.human) if variable.save responds end |
#destroy ⇒ Object
43 44 45 46 |
# File 'app/controllers/base_controller.rb', line 43 def destroy flash[:success] = I18n.t('destroyed', model: model.model_name.human) if variable.destroy redirect_to index_path end |
#edit ⇒ Object
29 30 |
# File 'app/controllers/base_controller.rb', line 29 def edit end |
#index ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/base_controller.rb', line 12 def index if included_attributes instance_variable_set(collection_instance_variable, model.includes(included_attributes).paginate(page: params[:page], per_page: PER_PAGE)) else instance_variable_set(collection_instance_variable, model.paginate(page: params[:page], per_page: PER_PAGE)) end search respond_with collection_variable end |
#new ⇒ Object
25 26 27 |
# File 'app/controllers/base_controller.rb', line 25 def new instance_variable_set(instance_variable, model.new) end |
#show ⇒ Object
22 23 |
# File 'app/controllers/base_controller.rb', line 22 def show end |
#template_not_found ⇒ Object
48 49 50 |
# File 'app/controllers/base_controller.rb', line 48 def template_not_found redirect_to '/404.html' end |
#update ⇒ Object
38 39 40 41 |
# File 'app/controllers/base_controller.rb', line 38 def update flash[:success] = I18n.t('updated', model: model.model_name.human) if variable.update(permit_params) responds end |