how do forms pass the id to the controller in normal basic scaffolding

8 views
Skip to first unread message

fugee ohu

unread,
Jun 4, 2018, 4:31:35 AM6/4/18
to Ruby on Rails: Talk
How do forms pass the id to the controller in normal basic scaffolding? There's no id field in the form, there's no magic that passes the form's container object to the controller, rather every parameter is explicity provided in input fields of the form, except the id, so how does the id get passed to the controller? Something in the forms syntax extracts the id from the @object and puts it in the form but i dunno what Thanks in advance

Walter Lee Davis

unread,
Jun 4, 2018, 8:35:19 AM6/4/18
to rubyonra...@googlegroups.com
Did you look in the params hash that is sent from your form when you submit it? What's the very last element in the params (usually, and in a scaffolded demo, always)? Note: I am speaking of the params you would get in an update (PATCH), not a create (POST), as you asked specifically about the id, and a POST won't have one of those.

Walter

> On Jun 4, 2018, at 4:31 AM, fugee ohu <fuge...@gmail.com> wrote:
>
> How do forms pass the id to the controller in normal basic scaffolding? There's no id field in the form, there's no magic that passes the form's container object to the controller, rather every parameter is explicity provided in input fields of the form, except the id, so how does the id get passed to the controller? Something in the forms syntax extracts the id from the @object and puts it in the form but i dunno what Thanks in advance
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7cb29d22-b82a-4101-aaa3-a054a556dfdf%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages