Multiple objects in a Rails form
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to edit multiple items of my model photo in one form. I am unsure of how to correctly present and POST this with a form, as well as how to gather the items in the update action in the controller. This is what I want: The parameters are just an example, like I stated above: I am not sure of the best way to POST these values in this form. In the controller I want to something like this: @photos = Photo.find( params[photos] ) @photos.each do |photo| photo.update_attributes!(params[:photos][photo] ) end 回答1: In Rails 4, just this ...