Class: Jabysoft::BaseController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Jabysoft::BaseController
- Defined in:
- app/controllers/jabysoft/base_controller.rb
Constant Summary collapse
- PER_PAGE =
8
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
31 32 33 34 35 |
# File 'app/controllers/jabysoft/base_controller.rb', line 31 def create instance_variable_set(instance_variable, model_class.new(permit_params)) flash[:success] = I18n.t('created', model: model_class.model_name.human) if variable.save responds :create end |
#destroy ⇒ Object
42 43 44 45 |
# File 'app/controllers/jabysoft/base_controller.rb', line 42 def destroy flash[:success] = I18n.t('destroyed', model: model_class.model_name.human) if variable.destroy redirect_to index_path end |
#edit ⇒ Object
25 |
# File 'app/controllers/jabysoft/base_controller.rb', line 25 def edit; end |
#index ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/jabysoft/base_controller.rb', line 14 def index if included_attributes instance_variable_set(collection_instance_variable, model_class.includes(included_attributes).paginate(page: params[:page], per_page: PER_PAGE)) else instance_variable_set(collection_instance_variable, model_class.paginate(page: params[:page], per_page: PER_PAGE)) end search respond_with collection_variable end |
#new ⇒ Object
27 28 29 |
# File 'app/controllers/jabysoft/base_controller.rb', line 27 def new instance_variable_set(instance_variable, model_class.new) end |
#show ⇒ Object
24 |
# File 'app/controllers/jabysoft/base_controller.rb', line 24 def show; end |
#update ⇒ Object
37 38 39 40 |
# File 'app/controllers/jabysoft/base_controller.rb', line 37 def update flash[:success] = I18n.t('updated', model: model_class.model_name.human) if variable.update(permit_params) responds :update end |