azback5 said over 3 years ago on User Notifications :
Hey  ... I'm having some trouble implementing the notifications feature into my rails app.

The notifications counter updates perfectly in my app layout view, but when I try to click on the notifications url I keep receiving a 500  NameError and it's parsing through and fussing with a link to root_path in my app/layout which doesn't make sense, to me as I know that works fine.


in my comment.rb model

class Comment < ApplicationRecord


  after_commit :create_notifications, on: :create

  belongs_to :commentable, polymorphic: true
  has_many :comments, as: :commentable
  belongs_to :user, optional: true

  validates :body, presence: true

  def deleted?
    user.nil?
  end

  private

  def create_notifications
   Notification.create do |notification|
     notification.notify_type = 'commentable'
     notification.actor = self.user
     notification.user = self.commentable.user
     notification.target = self
     notification.second_target = self.commentable
   end
 end

end


in my views/notifications/_commentable.html.erb
<div class=''>
  <%= link_to notification.actor.email, main_app.user_path(notification.actor) %> has commented in

</div>

<div class=''>
  <%= notification.target.body %>
</div>


Do you have any ideas as to what might be creating the fuss?

Thanks a lot!

Aaron