【发布时间】:2010-06-09 16:48:31
【问题描述】:
在我的网站工具栏中,我想在红色圆圈中显示未读消息的数量,
所以我认为最好的方法是在 ApplicationController 中创建一个名为 update_notification 的方法:
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 中?),你认为这是最好的方法吗?
谢谢
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 render