Hi There, rails noob just trying to suss a few things out.
So I have 2 tables. 1 called Posts and the other called comments. On
one page I need to be able to edit both the information about the post
and the attributes of each comment for that post. So here is what the
array might look like:
(Inside the params hash)
“post” => [
{“id”=>28, “title” => “My Title!”}
]
“comments” => [
{“id” => 1, “title” => “My Comment”, “body” => “My Body”},
{“id” => 2, “title” => “My Comment”, “body” => “My Body”},
{“id” => 3, “title” => “My Comment”, “body” => “My Body”}
]
Now, in PHP i would name the fields something like this:
I was able to do this in rails as well using:
text_field “comment[][title]”
… Then I read somewhere else that people were doing something like
this
text_field “comment_1[title]”
and then parsing out the data.
Which one is better? I would tend to think that the array method above
is superior, but then again, I may have no clue what I am talking
about. Is there another method that I am not thinking of?
Thanks!!!