开发者

Controllers, views and accepts_nested_attributes_for

I have a view 'business', that contains 3 partials (about, hours, and vacations) that each have an edit mode. 'business' accepts_nested_attributes_for each of these. Should these 3 fo开发者_如何转开发rms all call the business controllers 'update' method and just save the nested attributes (meaning the same code could handle all 3 forms), and update the appropriate partial depending on which form was submitted? Or should they call their own controllers, i.e. hours form calls hours controller, etc.


Both approaches could be plausible depending on how you handle the submitted data for each of them. If you will be submitting only one of those sub-resources, it is logical to use their own controllers. If it makes sense to change and submit them all together at once, then go for the main resource's controller.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜