24. A Wildcard Route
app/routes.rb
route /too+t/, TootController, :toot
48b08205
25. Using the Path
app/controllers/toot_controller.rb
class TootController < Spectacular::Controller
def toot
@toot = @path.gsub('/','')
end
end
app/views/toot/toot.html.haml
%h1=@toot
48b08205
26.
27.
28. 404
• When we can’t figure out how to process a
request, that should be a “404”
• We can simply make a wildcard route
29. app/routes.rb
route //, ErrorController, :not_found
app/controllers/error_controller.rb
class ErrorController < Spectacular::Controller
def not_found
@response_code = 404
end
end
2a2653b2
30.
31. What’s Left
• Only renders HAML
• No layouts
• Can’t easily render a different view
• No query parameters
• No POST