My homepage (or welcome page) will consist of data from two models (lets call them authors and posts). I am new to rails and not sure what is the best way to accomplish this
This answer is as of Rails 3.2.1.
First set up a Controller for pages, named for example static
:
$ rails generate controller static
In file app/controllers/static_controller.rb
:
class StaticController < ApplicationController
def index
end
end
Create the new View file app/views/index.html.erb
And finally configure your config/routes.rb
:
MyApp::Application.routes.draw do
match 'home', :to => "static#index"
root :to => "static#index"
end
This will make both /home
and /
go to whatever you put in the View file you just created.