开发者

Displaying and updating multiple models in one view

I have 3 different models, business_info, business_hours, business_vacations.

I have on开发者_开发知识库e view that displays all that information, so I made a new controller called business_all to gather all that info.

But when it comes to editing the individual parts within the page I'll be calling each of those 3 individual controllers to update, delete etc, then send back the updated data for that particular model.

Given that, should I skip having the business_all controller and instead, when the view is loaded have 3 ajax calls to each controller to get the relevant info?


one alternative is to make a non persisting model called business_all that has fields that combine the three models with its own validation and so on. and when persisting it actually saves to the actual models.

this way doing the forms and so on are easier as you can do form_for (BusinessAll.new ... ...) and so on.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜