Class: Jabysoft::BaseController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/jabysoft/base_controller.rb

Constant Summary collapse

PER_PAGE =
8

Instance Method Summary collapse

Instance Method Details

#createObject



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

#destroyObject



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

#editObject



25
# File 'app/controllers/jabysoft/base_controller.rb', line 25

def edit; end

#indexObject



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

#newObject



27
28
29
# File 'app/controllers/jabysoft/base_controller.rb', line 27

def new
  instance_variable_set(instance_variable, model_class.new)
end

#showObject



24
# File 'app/controllers/jabysoft/base_controller.rb', line 24

def show; end

#updateObject



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