Forum: Ruby on Rails How to pass an array of model objects on a view

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
sven (Guest)
on 2007-07-18 13:59
(Received via mailing list)

I am just beginning to understand how ruby on rails works. I have the
following problem:

In the controller I would like to create an array of model objects:

@arr_journeys =,

In the view I would like to do the following:

<% for i in 1..4 %>
       <%= text_field(@arr_journeys[i], :quantity, :size => 6 %)>
<% end>

Is there any chance to do it like this? Do I have to write my own

Greets & thanks

Chris H. (Guest)
on 2007-07-18 14:36
(Received via mailing list)
you almost got it

@arr_journeys = ...

<% @arr_journeys.each do |journey| -%>
<% end -%>
This topic is locked and can not be replied to.