Class: ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/application_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

> Create



45
46
47
48
# File 'app/controllers/application_controller.rb', line 45

def create
  @content = Node.new node_params
  respond_with @content, location: -> { application_path(@content) }
end

#newObject

> New



39
40
41
42
# File 'app/controllers/application_controller.rb', line 39

def new
  @content = Node.new
  respond_with @content
end

#robotsObject



61
62
63
64
# File 'app/controllers/application_controller.rb', line 61

def robots
  expires_in 5.hours, public: true
  render plain: "User-agent: *"
end

#showObject

> Specific page content

> All slugrouter requests passed here (including root)

> Liquid ref - github.com/Shopify/liquid/wiki/Liquid-for-Programmers#first-steps

> If not using bang operator in find, use || “No Content”

Raises:

  • (ActionController::RoutingError)


29
30
31
32
# File 'app/controllers/application_controller.rb', line 29

def show
  raise ActionController::RoutingError.new('Not Found') if params[:id] == "index"
  @content = Node.find_by_slug! params[:id] || "index"
end

#updateObject

> Update



51
52
53
54
# File 'app/controllers/application_controller.rb', line 51

def update
  @content = Node.find_by_slug! params[:id]
  respond_with @content, location: -> { application_path(@content) }
end