Class: Guts::MetafieldsController

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

Overview

Metafields controller

Instance Method Summary collapse

Methods included from MultisiteConcern

#current_site, #with_current_site

Methods included from SessionsHelper

#current_user, #log_in, #log_out, #logged_in?

Instance Method Details

#createObject

Note:

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

Creates a metafield through post



21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/guts/metafields_controller.rb', line 21

def create
  @metafield = Metafield.new metafield_params

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

#destroyObject

Note:

Redirects to #index on success

Destroys a single metafield



54
55
56
57
58
59
# File 'app/controllers/guts/metafields_controller.rb', line 54

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

#editObject

Editing of a metafield



38
39
# File 'app/controllers/guts/metafields_controller.rb', line 38

def edit
end

#indexObject

Displays a list of metafields



10
11
12
# File 'app/controllers/guts/metafields_controller.rb', line 10

def index
  @metafields = @object.metafields
end

#newObject

Creation of a new metafield



15
16
17
# File 'app/controllers/guts/metafields_controller.rb', line 15

def new
  @metafield = Metafield.new
end

#showObject

Shows details about a single metafield



33
34
# File 'app/controllers/guts/metafields_controller.rb', line 33

def show
end

#updateObject

Note:

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

Updates a metafields through patch



43
44
45
46
47
48
49
50
# File 'app/controllers/guts/metafields_controller.rb', line 43

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