的Ruby 1.9.3 + Rails的3.2.8模型访问
我有一个是在每一页上呈现在我的应用程序内部的局部视图:
<span id="sync-time">
<%= @sync.dropbox_last_sync.strftime('%b %e, %Y at %H:%M') %>
</span>
为了要使用我的syncs
模型,并有权访问dropbox_last_sync
方法,我必须将其包含在中,每个控制器贯穿我的应用程序。例如:
class EntriesController < ApplicationController
def index
@sync = current_user.sync
end
end
...
class CurrenciesController < ApplicationController
def index
@sync = current_user.sync
end
end
...等。
有没有一种办法可以让现有的syncs
模型处处包括它在我的应用程序控制器不知何故?
很好,谢谢! –