开发者

Best approach to multi-record forms in Rails

开发者 https://www.devze.com 2023-04-05 15:06 出处:网络
I\'ve been developing a Rails 3 application and I keep hitting issues when I\'m trying to create a form to allow a user to update multiple records in the model at once, I\'ve been through a few differ

I've been developing a Rails 3 application and I keep hitting issues when I'm trying to create a form to allow a user to update multiple records in the model at once, I've been through a few different approa开发者_如何学JAVAches (including a couple listed on SO) but not found one that works particularly well.

My question is what's the most recommended way to do it? Ideally I'd like to be able to just have one form, multiple fields per record, multiple records per form and one submit button to update all at once. Should I be looking at iterating them, going outside of the standard Rails form methods, or doing something like Flickr and having multiple submit buttons and using AJAX to update without leaving the page?

Edit: Ask for the model and ye shall receive.

class Content < ActiveRecord::Base

attr_accessible :body

end

There's not much going on in it at the moment. There's the accessible field of body, then a non-accessible field called title, the title is linked to a specific page on the site, then the body is linked to the content of the specific page.

0

精彩评论

暂无评论...
验证码 换一张
取 消