现在我正在这样做。这应该是正常的吗?
或者还有其他方法可以以另一种方式做到这一点,哪种方式更受欢迎?
users_controller.rb
before_filter :set_variable
def set_variable
@number_of_records_to_display = 10
@number_of_tags_to_display = 10
end
def index
...
@users = User.find_by_username(params[:id]).all_following(order: 'updated_at DESC')
@users = Kaminari.paginate_array(@users).page(params[:page]).per(@number_of_records_to_display)
@tags = User.tag_counts_on(:tags, :limit => @number_of_tags_to_display, :order => "id desc")
...
end