Forum: Ruby on Rails arrays in model objects

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.
2a73a242ac582b27e841b4bce6ba1373?d=identicon&s=25 Kamil Kukura (Guest)
on 2006-03-03 14:47
(Received via mailing list)
Having a dumb model object like

def MyModel
   attr_accessor :property

   def initialize
     @property = Array.new
   end
end


when it is used for for interaction by "@object = MyModel.new" and then
used in view as

   <%= text_field 'object', 'property' %>

shoudn't it be rendered as?:

   <input type="text" name="object[property][]"/>

that is with [] at the end so params[:property] will gain array?

--
Kamil
F59329dc91cba06600ff65c85fd3e93c?d=identicon&s=25 Anthony Green (acgreen)
on 2006-03-03 18:26
>
>    <%= text_field 'object', 'property' %>
>
> shoudn't it be rendered as?:
>
>    <input type="text" name="object[property][]"/>

Should it be

<%= text_field 'object', @property %>

 ?

Tony
This topic is locked and can not be replied to.