Rails for Zombies 1 5: Routes - mikesabat/LR_HF GitHub Wiki
Routes
The routes.rb file lives in the config directory and maps the link paths and the actions.
The "resources" command gives the application it's RESTful resources and sets the default routes.
- Code: tweets_path -- URL: /tweets -- Action: def index
- Code: tweets -- URL: tweet/id -- Action: def show
- Code: new_tweet_path --URL: tweet/new -- Action: def new
- Code: edit_tweet_path(tweet) -- URL: tweet/id/edit -- Action: def edit
Syntax
match'url string' => 'Controller#Action'
root :to => 'Controller#Action'
Redirects
match 'all' => redirect('/tweets')
match 'google => redirect('http://google.com')
Need to rewatch the end. It's confusing http://railsforzombies.org/levels/5