Class: ApplicationController

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

Instance Method Summary collapse

Instance Method Details

#createObject

> Create



42
43
44
45
# File 'app/controllers/application_controller.rb', line 42

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

#newObject

> New



36
37
38
39
# File 'app/controllers/application_controller.rb', line 36

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

#robotsObject



58
59
60
61
# File 'app/controllers/application_controller.rb', line 58

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)


26
27
28
29
# File 'app/controllers/application_controller.rb', line 26

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

#updateObject

> Update



48
49
50
51
# File 'app/controllers/application_controller.rb', line 48

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