How to pass an array of model objects on a view


#1

hello,

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 = Array.new(3, Journey.new)

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
helpers?

Greets & thanks

Sven


#2

you almost got it

@arr_journeys = …

<% @arr_journeys.each do |journey| -%>

<% end -%>