Module: EIVO::Concerns::Resources

Extended by:
ActiveSupport::Concern
Defined in:
app/controllers/eivo/concerns/resources.rb

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/eivo/concerns/resources.rb', line 20

def create
  @object ||= collection.new
  @object.assign_attributes(object_params_create)

  if @object.save
    redirect_to action: :index
  else
    render :new
  end
end

#destroyObject



46
47
48
49
50
51
# File 'app/controllers/eivo/concerns/resources.rb', line 46

def destroy
  @object ||= collection.find(params[:id])
  @object.destroy

  redirect_to action: :index
end

#editObject



31
32
33
# File 'app/controllers/eivo/concerns/resources.rb', line 31

def edit
  @object ||= collection.find(params[:id])
end

#indexObject



8
9
10
# File 'app/controllers/eivo/concerns/resources.rb', line 8

def index
  @objects ||= collection_index
end

#newObject



16
17
18
# File 'app/controllers/eivo/concerns/resources.rb', line 16

def new
  @object ||= collection.new
end

#showObject



12
13
14
# File 'app/controllers/eivo/concerns/resources.rb', line 12

def show
  @object ||= collection_show.find(params[:id])
end

#updateObject



35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/eivo/concerns/resources.rb', line 35

def update
  @object ||= collection.find(params[:id])
  @object.assign_attributes(object_params_update)

  if @object.update(object_params_update)
    redirect_to action: :index
  else
    render :edit
  end
end