Hey all,

trying to get a concept down.  Or maybe the syntax.

Here is the code:

<p>Phones</p>

<p><% @person.phones.each { |phone| %>
<%= tag("input", "type" => "text",  "id" =>
"phones[#{phone.id}][phone]", "name" => "phones[#{phone.id}][phone]",
"value" => phone.phone) %>

<%= phone.errors.on "phone" %><br/>
<% } %></p>

<p>Add new phone: (More phones can be added later)<br />
<input type="text" id="phones[new][phone]" name="phones[new][phone]"
value="">

</p>


What, exactly, is the [phone] in phones[#{phone.id][phone]?  I know
phones is the db phones.  I know phone id is the PK (and for
phones[new][phone].  What is phone though? Also,  in phones[new][phone],
what is new creating/doing?

Similarly:

def update
     @person = Person.find(@params["person"]["id"])

     @person.attributes = @params["person"]

     if @person.save
       redirect_to :action => "show", :id => @person.id
     else
       render "person/edit"

     end
end

What is ["person"]?  What is it referencing?

Thanks.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to