0

I try to store an activity using #create_activity from the public_activity gem:

Model

class Group < ActiveRecord::Base
  include PublicActivity::Common
end

Controller

def send_invitation
    @user = User.where(email: params[:user][:email])
    @user.create_activity :send_invitation, owner: @group, recipient: @user
    redirect_to root_path
end

The error

undefined method `create_activity' for #User::ActiveRecord_Relation:0x007febb0f0a610

clement
  • 71
  • 5

1 Answers1

0

Use should use
@user = User.where(email: params[:user][:email]).first instead. Without first, it return an ActiveRecord Relation as specified in the error

Vu Minh Tan
  • 526
  • 4
  • 6