活动源不使用公共活动gem rails显示记录

时间:2014-03-18 07:27:55

标签: ruby-on-rails ruby-on-rails-3 public-activity

我想在仪表板页面上显示我缺席的活动Feed。我正在使用公共活动宝石。

在我的模态中,我添加了

absence.rb

 class Absence < ActiveRecord::Base
  include PublicActivity::Model
  tracked

  belongs_to :user
  has_many :amendments
 end

我想修改活动Feed

在我的控制器中

 class HomeController < ApplicationController
  def index
   @user = User.new(params[:id])
   if user_signed_in?
    @activities = PublicActivity::Activity.order("created_at desc")
    redirect_to dashboard_users_path
   else
    redirect_to new_user_session_path
   end
  end
 end

在我看来

  %h1 Activity Feed
  - @activities.each do |activity|
    = activity.inspect

但是这给了我每个nde的Undefined方法:Nil class。我关注http://railscasts.com/episodes/406-public-activity?view=asciicast为什么我会收到这样的错误?

1 个答案:

答案 0 :(得分:1)

您添加到应用程序控制器是: include PublicActivity::StoreController