I'm trying to deploy the chat demo from DHH on AWS Elastic Beanstalk. I've followed the tutorial here: https://keithpblog.wordpress.com/2015/12/30/rails-5-tutorial-chat-app-can-we-deploy-it And I've managed to get the solution deployed in a single instance and Redis up and running too. But when I try to post something, the message is saved in the db, but not returned by the WebSocket. I've checked the production.log and I can see this error message:
E, [2016-05-20T20:33:52.676577 #24281] ERROR -- : There was an exception - Gem::LoadError(Specified 'redis' for Action Cable pubsub adapter, but the gem is not loaded. Add gem 'redis' to your Gemfile (and ensure its version is at the minimum required by Action Cable).)
E, [2016-05-20T20:33:52.676826 #24281] ERROR -- : /opt/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/actioncable-5.0.0.rc1/lib/action_cable/server/configuration.rb:37:in `rescue in pubsub_adapter'
/opt/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/actioncable-5.0.0.rc1/lib/action_cable/server/configuration.rb:34:in `pubsub_adapter'
I also have in my Gemfile:
gem 'redis', '~>3.2'
Any Ideas? Thanks!
I fixed the error by adding to my Gemfile:
gem 'em-hiredis'
gem 'redis'
The other change that I had to make was on /environments/production.rb
config.action_cable.url = 'ws://url.com/cable'
config.action_cable.allowed_request_origins = ['http://url.com']
And with that, I have actioncable up and running on Elastic Beanstalk
Related
I'm trying to use omniauth-linkedin-oauth2 on RoR 5.0.7.
gem 'devise'
gem 'omniauth'
gem 'omniauth-oauth2'
gem 'omniauth-linkedin-oauth2'
but I got an error on production environment and I can not start rails apps. My local developing environment is no problem to run it.
The error on production.log is
NameError (uninitialized constant OAuth Did you mean? OAuth2)
if I replaced
gem 'omniauth-linkedin-oauth2'
to
gem 'omniauth-linkedin'
and bundle update then there is no errors and RoR is running.
My production environment is
Debian GNU/Linux 8.11 (jessie)
Apache/2.4.10 (Debian)
Phusion_Passenger/6.0.2
ruby 2.4.6p354
You need to clear the session data to remove the existing OAuth token data. You can't use both token types simultaneously.
Per your comment (leaving an answer in case someone else has this same problem) you need to run:
RAILS_ENV=production rake db:sessions:clear
I am using the following gems in my application.
gem 'activerecord-session_store'
gem 'sidekiq'
gem 'sidekiq-unique-jobs'
gem 'sidekiq-cron'
gem 'sinatra', require: false
gem 'capistrano-sidekiq', github: 'seuros/capistrano-sidekiq'
I recently started using activerecord-session_store and in the process I remember having to update my secret_key_base for my application. Now when I try to make changes through the SideKiq admin panel I always get a blank white page that says "forbidden". I'm guessing that my session is not being shared correctly? How can I set up SideKiq to use the same secret_key_base as my application?
You can do the following to share Rails' secret key base with Sidekiq web interface:
Sidekiq::Web.set :session_secret, Rails.application.secrets[:secret_key_base]
I am receiving the following error message when attempting to authenticate with Facebook in a rails app using MongoMapper:
It appears that MongoMapper is not being loaded properly, but I am not sure why. In my Gemfile I include gem 'mongo_mapper, gem 'bson_ext', and gem 'omniauth-facebook', '~> 1.4.1'. I also followed the setup instructions here: http://mongomapper.com/documentation/getting-started/rails.html to completion. I am able to run the $ mmconsole, as well as connect to the mongod using the $ mongo. Is there another configuration step that I missing to ensure that mongo_mapper can be loaded properly? Thanks in advance for any assistance, I am new to MongoDB in general.
EDIT:
Here is what my SessionsController looks like, where the LoadError originates:
I'm using a gem for gmail in my Rails app. My Gemfile contains:
gem 'gmail-api-ruby', :require => 'Gmail'
And in my controller, I initialize the gem with (using devise/omniauth to get the refresh_token from Google):
Gmail.client_id = ENV['CLIENT_ID']
Gmail.client_secret = ENV['CLIENT_SECRET']
Gmail.refresh_token = current_user.refresh_token
This works fine in development, but when I deploy to Heroku, I get the following error:
/app/vendor/bundle/ruby/2.2.0/gems/bundler-1.7.12/lib/bundler/runtime.rb:76:in `require': cannot load such file -- Gmail (LoadError)
I cannot figure out why. Should I be requiring the gem somewhere else in my app?
Ruby 2.2.0
Bundler: 1.8.5
Rails: 4.2.0
require is case sensitive if the underlying filesystem is case sensitive (which it is on linux, which is what underpins heroku)
Change to :require => 'gmail' instead of Gmail and you should be ok.
Just remove useless require option from your Gemfile because bundler can load classes inside of this gem without specify require option in your case.
gem 'gmail-api-ruby', '~> 0.0.10'
and run bundle install.
FYI: read section about require option here.
I'm trying to push a Rails application to AppFog and I keep getting a 301 error.
It gets to Staging, so it shows up on my AppFog account, but refuses to activate. Trying to update it succeeds, but has the same problem where it won't activate and only shows a 404 error.
Here is the message text:
$ af push RubyMongoGranny --runtime=ruby193
Would you like to deploy from the current directory? [Yn]:
Pushing application 'RubyMongoGranny'...
Creating Application: OK
Binding Service [ruby_mongo_granny]: OK
Uploading Application:
Checking for available resources: OK
Processing resources: OK
Packing application: OK
Uploading (236K): OK
Push Status: OK
Staging Application 'RubyMongoGranny': ..........Error 310: Staging failed: 'Staging task failed:
Staging plugin failed: /opt/cloudfoundry/vcap/staging/lib/vcap/staging/plugin/gemfile_task.rb:325:in `log_and_raise_error': Error resolving Gemfile: Error parsing Gemfile: /tmp/d20130401-19438-h0d0st/Gemfile not found (RuntimeError)
from /opt/cloudfoundry/vcap/staging/lib/vcap/staging/plugin/gemfile_task.rb:50:in `specs'
from /opt/cloudfoundry/vcap/staging/lib/vcap/staging/plugin/gemfile_task.rb:103:in `gem_info'
from /opt/cloudfoundry/vcap/staging/lib/vcap/staging/plugin/gemfile_support.rb:86:in `gem_info'
from /opt/cloudfoundry/vcap/staging/lib/vcap/staging/plugin/rails3/plugin.rb:188:in `rails_version'
from /opt/cloudfoundry/vcap/staging/lib/vcap/staging/plugin/rails3/plugin.rb:199:in `precompile_assets'
from /opt/cloudfoundry/vcap/staging/lib/vcap/staging/plugin/rails3/plugin.rb:85:in `block in stage_application'
from /opt/cloudfoundry/vcap/staging/lib/vcap/staging/plugin/rails3/plugin.rb:76:in `chdir'
from /opt/cloudfoundry/vcap/staging/lib/vcap/staging/plugin/rails3/plugin.rb:76:in `stage_application'
from /opt/cloudfoundry/vcap/stager/bin/run_plugin:19:in `<main>'
My gemfile looks like:
source 'https://rubygems.org'
gem 'rails'
gem 'mongo_mapper'
gem 'bson_ext'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'cloudfoundry-jquery-rails
==UPDATE==
Changed
config.server_static_assets = false
to
config.server_static_assets = true
and precompiled my assets?
bundle exec rake assets:precompile
but it still gives me the same error.
Changed
gem 'jquery-rails'
to
gem 'cloudfoundry-jquery-rails'
still no success
Did you change in your config/environments/production.rb
config.server_static_assets = false
to
config.server_static_assets = true
and precompiled your assets?
bundle exec rake assets:precompile
Also, for Ruby 1.9 AppFog requires a tweak to the jquery-rails gem. Remove or comment out gem 'jquery-rails' and add gem 'cloudfoundry-jquery-rails', like so:
# gem 'jquery-rails'
gem 'cloudfoundry-jquery-rails'
Further documentation here.
Didn't really come up with a good solution for this problem. However, I created a brand new rails app and moved all of my files from the old one to the new one. Now it will push to AppFog.
I did a diff of the directory, but all the differences are just log files, the app name, and the readme file. Nothing really stands out as a possible cause of the error.