What’s the difference between these two?
Objective:
Trying to display the addresses of the students that has “has_many”
relations with addresses
"} %>
This code worked:
<% end %>
Any comments appreciated.
Thanks
Silvy Mathews
What’s the difference between these two?
Objective:
Trying to display the addresses of the students that has “has_many”
relations with addresses
This code worked:
Any comments appreciated.
Thanks
Silvy Mathews
Hi,
You shouldn’t need the <% end %> because you are passing in a block.
This should work as well.
<% @student.addresses.each {|address| %>
<%= address.addr1 %>
<% } %>
Eric
[email protected] wrote:
<% @student.addresses.each do |address|%> [email protected] http://lists.rubyonrails.org/mailman/listinfo/rails
–
Eric G.
http://www.ericgoodwin.com
Well first of all, when you’re iterating through a block, you don’t
need to have an end. In fact it should give you some kind of error.
Secondly, <% just evals a statement, <%= renders the output. So your
loop should be:
Pat
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs