rails-engine / notifications

🛎 Notifications Center engine like GitHub or other application for any Rails applications.
MIT License
389 stars 42 forks source link

searching the partial in the gems? #18

Closed dcalixto closed 5 years ago

dcalixto commented 6 years ago
ActionView::MissingTemplate in Notifications::Notifications#index
Showing /home/daniel/jexts/app/views/notifications/notifications/_notification.html.erb where line #11 raised:

Missing partial notifications/_comment with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :jbuilder]}. Searched in:
  * "/home/daniel/jexts/app/views"
  * "/home/daniel/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/kaminari-core-1.1.1/app/views"
  * "/home/daniel/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/notifications-0.6.0/app/views"
  * "/home/daniel/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/mailboxer-0.15.1/app/views"
  * "/home/daniel/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/devise-4.4.1/app/views"
huacnlee commented 6 years ago

You need add app/views/notifications/_comment.html.erb for write template for comment type/

dcalixto commented 6 years ago

@huacnlee thank you, just one doubt, i added in right place, but now show Showing

/home/daniel/jexts/app/views/notifications/_comment.html.erb where line #2 raised:
undefined method `user_path' for #<#<Class:

and if i remove the link_to from the partial shows:

/home/daniel/jexts/app/views/notifications/_comment.html.erb:2: syntax error, unexpected ')', expecting '=' ....username, notification.actor );@output_buffer.safe_append='... ... ^ /home/daniel/jexts/app/views/notifications/_comment.html.erb:5: syntax error, unexpected keyword_ensure, expecting ')'

huacnlee commented 6 years ago

https://github.com/rails-engine/notifications/blob/master/test/dummy/app/views/notifications/_comment.html.erb#L3

huacnlee commented 6 years ago

https://github.com/rails-engine/notifications/pull/19/files

dcalixto commented 6 years ago

so, i have to change the will_paginate to kaminari?

huacnlee commented 6 years ago

You can rewrite notifications_controller.rb to use will_paginate

https://github.com/rails-engine/notifications/blob/master/app/controllers/notifications/notifications_controller.rb#L4

# app/controller/notifications_controller.rb
class NotificationsController < Notifications::NotificationsController
  def index
    @notifications = Notification.where(user_id: current_user.id).includes(:actor).order('id desc').paginate(params[:page])

    unread_ids = @notifications.reject(&:read?).select(&:id)
    Notification.read!(unread_ids)

    @notification_groups = @notifications.group_by { |note| note.created_at.to_date }
  end
end

# config/routes.rb
resources :notifications
dcalixto commented 6 years ago

@huacnlee thank you very much! but if change to will_paginate

shows another issue:

undefined methodfetch' for nil:NilClass`

huacnlee commented 6 years ago

need more details / context of this error message