Ruby on Rails 3 .each do Problem

后端 未结 2 1889
滥情空心
滥情空心 2020-12-19 06:01

I\'m sort of new to Ruby on Rails and have been learning just fine, but have seem to run into a problem that I can\'t seem to solve.

Running Rails 3.0.9 & Ruby 1

相关标签:
2条回答
  • 2020-12-19 06:40

    .each returns the entire array at the end once it is finished the loop. <%= ... %> prints out the value of the statment, which is the value returned by .each <% ... %> does not. So you want:

    <% @events.each do |f| %>
        <%= f.name %><%= link_to "View", event_path(f) %><br/><hr/>
    <% end %>
    
    0 讨论(0)
  • 2020-12-19 06:47

    You should be using <%, not <%= for your .each line, so

    <%= @events.each do |f| %>
    

    should be

    <% @events.each do |f| %>
    
    0 讨论(0)
提交回复
热议问题