开发者

Model View Referencing Another Model View

I have an Article model and I also have a Comment model. My article show page is rendering a view from the Comment view开发者_Go百科s. It is rendering a new comment form and a show comment form. If I reference a variable in the comment form, like @comment, does it look for the @comment in the article controller or does it look for it in the comment controller?


The views are independent from the controllers. Only one controller will be accessed based on your routing settings, regardless if you include code from another view.

However, it sounds like you're doing things the "wrong" way. Article-Comment is a classic example of a nested resource and is probably what you're looking for. Try this article.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜