8

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?

10
  • Did you bundle install in production after adding it to the gemfile? Jul 31, 2012 at 17:54
  • Yes, my deploy script runs bundle install
    – w2bro
    Jul 31, 2012 at 18:26
  • what is the version of Rails are you running ? Jul 31, 2012 at 18:49
  • Currently running rails 3.2.7
    – w2bro
    Jul 31, 2012 at 18:53
  • Any chance that you put gem "private_pub" into a group in your Gemfile?
    – iltempo
    Aug 6, 2012 at 22:48

2 Answers 2

3

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
3
  • I'm unable to access private_pub/view_helpers in the initializer. I get a LoadError
    – w2bro
    Aug 10, 2012 at 19:52
  • 1
    Something is wrong with your production gems. I just created a new Rails 3 project and tested the initializer, it loads without issue. If the require is failing, it means the private_pub gem is not loaded. What command do you use to run your rails server?
    – mguymon
    Aug 10, 2012 at 21:12
  • yes it looks like my Debian server fails with this, but running Ubuntu on a different server hardware stack worked fine.
    – w2bro
    Aug 14, 2012 at 19:01
0

Is your deploy script starting Faye's rackup file? rackup private_pub.ru -s thin -E production

1
  • yes, I can load the faye.js file just fine. When I deploy the rails application it can't find the method subscribe_to
    – w2bro
    Aug 5, 2012 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.