Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I access this helper function in production?

I'm using private_pub for pushing notifications to subscribed clients to my users. In my application.html.haml I have:

...
= javascript_include_tag 'application'
= subscribe_to "/#{@user.access_token}/notifications"
...

The subscribe_to helper works fine in development. When deployed to production, the following error is logged:

ActionView::Template::Error (undefined method `subscribe_to' for #<#<Class:0x00000001f372e8>:0x00000001fded90>):
    5:     = stylesheet_link_tag 'application', :media => 'all'
    6:     = include_gon(:init => true)
    7:     = javascript_include_tag 'application'
    8:     = subscribe_to "/#{@user.access_token}/notifications"
    9:     = csrf_meta_tags
    10: 
    11:   %body
  app/views/layouts/application.html.haml:8:in `_app_views_layouts_application_html_haml__1867651381877570337_14592040'

How can I get access to this helper method in my production environment?

like image 200
w2bro Avatar asked Jul 31 '12 17:07

w2bro


1 Answers

This looks like an error with loading the PrivatePub engine. If you look at engine.rb, you see it is adding the PrivatePub view helpers as part of the init. Might be a bug if it is loading for the development, but not production environment.

Try and create a config/initializers that loads the PrivatePub helpers manually:

require 'private_pub/view_helpers'
ActionView::Base.send :include, PrivatePub::ViewHelpers
like image 92
mguymon Avatar answered Oct 31 '22 14:10

mguymon