Going a bit mad here.
@sport = Sport.find(params[:sport])
@activities = Activity.where("sport_id = ?", @sport)
@activites outputs fine with the below:
<% @activities.each do |a| %>
<%= a.id %>
<% end %>
showing 2 values as predicted.
My problem is, when I write (in the controller):
for a in @activities
@facilities = Facility.where("id = ?", a.facility_id)
end
My output for:
<% @facilities.each do |f| %>
<%= f.id %>
<% end %>
only returns 1 value. It should show 2 values as each of the above activities belong to different facilities. I think it is either something to do with the for loop OR when I define @facilities it is only registering one value.
Any help? Thanks :)
for, useeachormap, depending on your goal. The latter are idiomatic Ruby.