Skip to main content

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

Rails • Asked by Tolase Kelvin Adegbite

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


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 24,647+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.