TO SUM UP :
The module PgSearch provided by the Gem pg_search cannot be included, required or loaded on the staging environment (Rbenv, nginx, unicorn,capistrano), the problem happens on the web server through http but does not appear on the staging server's rails command. An other module provided by an other gem can be included without error.
No problem on the local development environment (rvm, puma).
I am currently developing a Ruby On Rails 4.0 application with ruby 2.0.0 which git repositories are hosted on bitbucket. I deploy the app through a staging server using capistrano.
The rails environnment files (environment/production.rb & environment/staging.rb) for both are the same.
WHAT DID I DO :
I have installed the pg_search gem (a PostgreSQL full text search gem) by adding it to my Gemfile and put the clause "include PgSearch" in the Active Record model I wanted to use with pg_search gem
I have run the app in development mode... it works !
PROBLEM :
After having deployed the changes to the staging server : Through the http server I get this error :
NameError in App::MyController#index Uninitialized constant MyActiveRecordModel::PgSearch
(Normally, this pg_search gem which is included in the GemFile should have its lib/*.rb files included in the autoload search path and a clause like load "pg_search.rb", require"pg_search" or "include PgSearch" (module included in pg_search.rb file) should pass.
In order to find clues to fix the bug, I have :
-tried if an other module provides by the gem could be included ... It works
After been to the current release path of the staging server I run "bundle exec rails c staging" and tried to :
see if the ActiveRecord Model ( which I included PgSearch) instanciation works.
see if the Module provided by the gem could be found / loaded on the server and I have executed - include PgSearch and require "pg_search" and load "pg_search.rb".
All these commands were a succeess.
Thank you.
Gems introduce new code that rails will need to access. To make the new code available to Rails we go through 3 steps:
Restart the rails server
It is easy to forget a step.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With