Rails forms and params

Another not to self: Rails has the cool feature that you it will map all the values from your submitted forms into the params hash. And, if you create input fields that are named “something[bla]“, it will automatically create a nested hash so that you will be able to access params[:thingyform][:something].

But what if you just have a list of things that you need to submit? In this case, just name multiple form fields something[], and the params will contain an array.

Advertisements

Comments are closed.

Create a free website or blog at WordPress.com.

Up ↑

%d bloggers like this: