ruby on rails - Build vs New problem -
Has anyone participated in this problem?
I have a collection of comments, in which I refer to general:
& lt;% & lt; % = Comment.body% & gt; & Lt;% end% & gt; But I also have a form of adding a comment, but it seems that if I use @ post.comments. Instead of commenting in the controller. Instead of the numerator, it's a 'comment' in an empty frequency loop.
I like to use. Do not build.No, have anybody encountered this? Is there a hack?
Thanks
Funny you mention, I had to face it Days before
I ended with Model.new but you can try to reload after calling even after calling build Are there.
@ post.comments (true) will reload it. (You can also write @ post.comments (: force_reload) for readability.)
The option to reload may be that the all Named Area Association, therefore @ post.comments.all .
I think both will continue to issue a new query, but they will probably affect the query cache.
Comments
Post a Comment