Search code examples
ruby-on-railsrubyruby-on-rails-3rails-for-zombies

Rails for Zombie Level 5, Challenge 1


I'm not actually sure what they are asking me to do.

This is the question:

Create a resources route for zombies

Resources:

class ZombiesController < ApplicationController
  def index
    render :text => 'success', :layout => nil
  end
end

My code:

RailsForZombies::Application.routes.draw do
  match 'zombie' => 'Zombies#index'
end

I'm not sure what it means by a 'resources route'; I at first assumed it wanted me to set a parameter in the url to match, but there is nothing to match to in the controller. Could someone please explain this?


Solution

  • "Match" is for matching URL strings to a controller/action.

    A resource route looks like this:

    resources :photos

    You use the "plural" of the word. What that does is gives you the 7 "rest" urls for photos. New, create, edit, update, show, destroy and index.

    But you need a table in your database called Photos for this to work.

    http://guides.rubyonrails.org/routing.html