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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D824b41a6ca0b086be457345139caeeb?d=identicon&s=25 sven (Guest)
on 2007-07-18 11:59
(Received via mailing list)
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
A2c85dc5ee81b12e3cc0a6522e8d079d?d=identicon&s=25 Chris Hall (au5lander)
on 2007-07-18 12: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.