home_controller.rb
class HomeController < ApplicationController
def index
batman = Superhero.new
batman.name = 'BATMAN'
batman.alias = 'Bruce Wayne'
batman.age = 27
batman.friends = 'dead'
batman.powers = 'justice'
batman.save
@heroes = Superhero.all
end
end
index.html.erb
<h1>Supereroes aren't hard to find</h1>
<% @heroes.each do |hero| %>
<li><%= hero.name %> (has an alias of <%= hero.alias %>)</li>
<% end %>
home_controller.rb
will automatically have views mapped by methods rendered to /views/controller_name/method_name.html.erb
We don't have to explicitly call erb :view_file
to render ERB Views like in Sinatra.