<%= link_to pluralize(Notification.unread_count(@current_user), 'Notification'), notifications_path %>
undefined local variable or method `root_path' for #<#<Class:0x00007fb4d1e8b498>:0x00007fb4d91abd38> Did you mean? font_path
<%= render partial: "/notifications/#{notification.notify_type}", locals: { notification: notification } %>
timesink/app/views/notifications/notifications/_notification.html.erb where line #11 raised:issing partial notifications/_comment with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :arb, :jbuilder]}. Searched in: * "/Users/aaronzomback/Sites/timesink/app/views" * "/Users/aaronzomback/.rvm/gems/ruby-2.7.0/gems/notifications-1.1.0/app/views" * "/Users/aaronzomback/.rvm/gems/ruby-2.7.0/gems/devise-4.7.2/app/views" * "/Users/aaronzomback/.rvm/gems/ruby-2.7.0/gems/activeadmin-2.7.0/app/views" * "/Users/aaronzomback/.rvm/gems/ruby-2.7.0/gems/kaminari-core-1.2.1/app/views" * "/Users/aaronzomback/.rvm/gems/ruby-2.7.0/gems/form_slider-0.0.5/app/views" * "/Users/aaronzomback/.rvm/gems/ruby-2.7.0/gems/actiontext-6.0.3.2/app/views" * "/Users/aaronzomback/.rvm/gems/ruby-2.7.0/gems/actionmailbox-6.0.3.2/app/views"
class Comment < ApplicationRecord belongs_to :commentable, polymorphic: true has_many :comments, as: :commentable belongs_to :user, optional: true acts_as_votable validates :body, presence: true def deleted? user.nil? end after_commit :create_notifications, on: :create 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
NoMethodError (undefined method `user' for #<BlogPost:0x00007fc3cab54fd8>
Did you mean? super):
app/models/comment.rb:26:in `block in create_notifications'
app/models/comment.rb:23:in `create_notifications'
app/controllers/comments_controller.rb:17:in `create'
if self.commentable = self notification.user = commentable.user end
def create @comment = @commentable.comments.new(comment_params) @comment.user = @current_user if @comment.save CommentNotifier.call(@comment) if @comment = @commentable else nil end respond_to do |format| format.html { redirect_to @commentable } format.js # create.js.erb end