Add WebSockets, live-updates and offline-first to Ruby on Rails with Logux. This gem will add Logux Back-end Protocol to Ruby on Rails and then you can use Logux Server as a proxy between WebSocket and your Rails application.
Read Creating Logux Proxy guide.
Add this line to your application's Gemfile:
gem 'logux_rails'And then execute:
bundleFirst of all, you have to configure Logux, by defining server address in, for example, config/initializers/logux.rb:
Logux.configure do |config|
  config.logux_host = 'http://localhost:31338'
endMount Logux::Rack in your application routing configuration:
# config/routes.rb
Rails.application.routes.draw do
  mount Logux::Engine => '/'
endAfter this, POST requests to /logux will be processed by LoguxController. You can redefine it or inherit from, if it necessary, for example, for implementing custom authorization flow.
Logux Rails will try to find Action for the specific message from Logux Server. For example, for project/rename action, you should define Action::Project class, inherited from Logux::Action base class, and implement rename method.
Use rails logux:actions command to get the list of available action types, or rails logux:channels for channels. The default search path is set to app/logux/actions and app/logux/channels for actions and channels correspondingly, assuming app directory is the root of your Rails application. Both command support custom search paths: rails logux:actions[lib/logux/actions].
After checking out the repo, run:
docker-compose run app bundle install
docker-compose run app bundle exec appraisal installRun tests with:
docker-compose run app bundle exec appraisal rspecRun RuboCop with:
docker-compose run app bundle exec rubocopThe gem is available as open source under the terms of the MIT License.