Home Page Question

I'm having trouble fully wrapping my head around how to setup a home page. What if I wanted to just have a home page that was for looks, and then a link to the restaurants, listings, or craiglists posts. For Craigslist we wrote Rails.application.routes.draw do resources :posts root 'posts#home' … end So for listings would it just be ... root 'listings#home' ..... and then make a link for listings with ... get 'listings' => "listings#index"

Posted about 5 years ago by Matt
Posted about 5 years ago by Alex Yang

That's right. To set a home page route, just use:

root 'listings#home'

where 'listings' is the name of your controller and 'home' is the action corresponding to the home page. Then if you only want the 'index' action for Listings (in other words, you don't need 'new', 'create', 'edit', etc), then use:

get 'listings' => 'listings#index'

which will set www.WEBSITE.com/listings to be the URL for displaying an index of all the Listings.