Class: Guts::MetafieldsController

Inherits:
ApplicationController show all
Includes:
ControllerPermissionConcern
Defined in:
app/controllers/guts/metafields_controller.rb

Overview

Metafields controller

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_ability

Methods included from MultisiteConcern

#current_site, #with_current_site

Instance Method Details

#createObject

Note:

Redirects to #index if successfull or re-renders #new if not

Creates a metafield through post



24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/guts/metafields_controller.rb', line 24

def create
  @metafield = Metafield.new metafield_params

  if @metafield.save
    flash[:notice] = 'Metafield was successfully created.'
    redirect_to edit_polymorphic_path([@object, @metafield])
  else
    render :new
  end
end

#destroyObject

Note:

Redirects to #index on success

Destroys a single metafield



57
58
59
60
61
62
# File 'app/controllers/guts/metafields_controller.rb', line 57

def destroy
  @metafield.destroy

  flash[:notice] = 'Metafield was successfully destroyed.'
  redirect_to polymorphic_path([@object, :metafields])
end

#editObject

Editing of a metafield



41
42
# File 'app/controllers/guts/metafields_controller.rb', line 41

def edit
end

#indexObject

Displays a list of metafields



13
14
15
# File 'app/controllers/guts/metafields_controller.rb', line 13

def index
  @metafields = @object.metafields
end

#newObject

Creation of a new metafield



18
19
20
# File 'app/controllers/guts/metafields_controller.rb', line 18

def new
  @metafield = Metafield.new
end

#showObject

Shows details about a single metafield



36
37
# File 'app/controllers/guts/metafields_controller.rb', line 36

def show
end

#updateObject

Note:

Redirects to #index if successfull or re-renders #edit if not

Updates a metafields through patch



46
47
48
49
50
51
52
53
# File 'app/controllers/guts/metafields_controller.rb', line 46

def update
  if @metafield.update metafield_params
    flash[:notice] = 'Metafield was successfully updated.'
    redirect_to edit_polymorphic_path([@object, @metafield])
  else
    render :edit
  end
end