在我的网站工具栏中,我想要显示未读消息数量的红色圆圈。所以我认为最好的方法是在ApplicationController中创建一个名为update_notification的方法:
在 application.html.erb 文件中,我显示如下内容:
问题在于我应该在哪里和何时调用update_notification方法(在ApplicationController中吗?)你认为这样做是最好的方式吗?
谢谢。
def update_notification
@notification = 42
# 42 is just for test
end
在 application.html.erb 文件中,我显示如下内容:
<%= render :partial => 'messages/notification' %>
_notification.html.erb :
<div id="notification">
<%= @notification %>
</div>
问题在于我应该在哪里和何时调用update_notification方法(在ApplicationController中吗?)你认为这样做是最好的方式吗?
谢谢。