Im using the public_activity gem. I have a post model, user model (generated with devise) and a profile model.
Using the public_activity gem I can get the news feed to show when a Post
is created, edited or deleted, but i need a way to show the users name associated with the Post
, the user name is stored in the Profile
model and not the User
model generated by devise
. Here is what I have so far:
User model:
class User < ActiveRecord::Base
has_many :posts
has_one :profile
end
post model:
class Post < ActiveRecord::Base
belongs_to :user
include PublicActivity::Model
tracked owner: Proc.new{ |controller, model| controller.current_user }
end
Profile model:
class Profile < ActiveRecord::Base
belongs_to :user
end
I have the standard views set up for example views/public_activity/post/_create.html.erb
<li class="list-group-item">
<% if a.trackable %>
<%= a.trackable.name %> was created.
<% else %>
An article that is currently deleted was added.
<% end %>
</li>
Im trying something like this to:
<div class="activities">
<% @activities.each do |activity| %>
<div class="activity">
<%= activity.owner.profile.name %>
<%= render_activities(@activities) %>
</div>
<% end %>
</div>
but this is not working, error is:
undefined method `profile' for nil:NilClass