I'm new to Ruby on Rails and to learn it I'm trying to make a simple application without scaffolding.
I generated a controller Foos, a model Foo and created 4 foos in the database. Then I tried to get /Foos/ and got an error. So I wrote
def index
@foos = Foo.all
end
in the controller and created a view.
The view looks like
<% @foos.each do 开发者_如何学Go|foo| %>
<div><% foo.name %></div>
<% end %>
The logs from console and from the server looks the same
Processing by FoosController#index as HTML
Foo Load (0.1ms) SELECT "foos".* FROM "foos"
But when I get Foos from the rails console it shows me foos and the view just creates 4 empty divs. Why? Did I miss something?
<% @foos.each do |foo| %>
<div><%= foo.name %></div>
<% end %>
You need equal sign for output to the view
精彩评论