Ask A Question

Notifications

You’re not receiving notifications from this thread.

"Undefined method error" while trying to implement In-App Notification.

Tolase Kelvin Adegbite asked in Rails

Hi people! I'm trying to implement this to an app am building (I want to create the notifications for comments where the comment belongs to episode and episode belongs to story and genre)... When i checked out Notification.all in my console it outputted it but when i navigated to http://localhost:3000/notifications.json i got an error telling me that "undefined method `episode_path' for #<#class:0x157f1538:0x15149e68>"

Here is my index.json.jbuilder

json.array! @notifications do |notification|
    json.id notification.id
    # json.recipient notification.recipient
    json.actor notification.actor.user_name
    json.action notification.action
    json.notifiable do #notification.notifiable
        json.type "a #{notification.notifiable.class.to_s.underscore.humanize.downcase}"
    end
    json.url episode_path(notification.notifiable.episode, anchor: dom_id(notification.notifiable))
end

Thank You

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,464+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.