hyper-model 0.6.0 → 0.99.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +35 -41
  3. data/.rspec +2 -0
  4. data/.travis.yml +33 -0
  5. data/CHANGELOG.md +34 -0
  6. data/DOCS.md +735 -0
  7. data/Gemfile +7 -0
  8. data/Gemfile.lock +298 -224
  9. data/{LICENSE → LICENSE.txt} +6 -6
  10. data/README.md +51 -2
  11. data/Rakefile +18 -0
  12. data/bin/console +14 -0
  13. data/bin/setup +7 -0
  14. data/codeship.database.yml +18 -0
  15. data/hyper-model.gemspec +62 -36
  16. data/lib/active_model_client_stubs.rb +16 -0
  17. data/lib/active_record_base.rb +331 -0
  18. data/{examples/chat-app/app/assets/images/.keep → lib/acts_as_string.rb} +0 -0
  19. data/lib/enumerable/pluck.rb +6 -0
  20. data/lib/hyper-model.rb +59 -8
  21. data/lib/hyper_model/version.rb +3 -0
  22. data/lib/hyper_react/input_tags.rb +47 -0
  23. data/lib/hyperloop/model/load.rb +1 -1
  24. data/lib/kernel/itself.rb +5 -0
  25. data/lib/object/tap.rb +7 -0
  26. data/lib/opal/equality_patches.rb +15 -0
  27. data/lib/opal/parse_patch.rb +14 -0
  28. data/lib/opal/set_patches.rb +8 -0
  29. data/lib/reactive_record/active_record/aggregations.rb +69 -0
  30. data/lib/reactive_record/active_record/associations.rb +118 -0
  31. data/lib/reactive_record/active_record/base.rb +10 -0
  32. data/lib/reactive_record/active_record/class_methods.rb +406 -0
  33. data/lib/reactive_record/active_record/error.rb +31 -0
  34. data/lib/reactive_record/active_record/errors.rb +374 -0
  35. data/lib/reactive_record/active_record/instance_methods.rb +187 -0
  36. data/lib/reactive_record/active_record/public_columns_hash.rb +44 -0
  37. data/lib/reactive_record/active_record/reactive_record/backing_record_inspector.rb +36 -0
  38. data/lib/reactive_record/active_record/reactive_record/base.rb +416 -0
  39. data/lib/reactive_record/active_record/reactive_record/collection.rb +558 -0
  40. data/lib/reactive_record/active_record/reactive_record/column_types.rb +75 -0
  41. data/lib/reactive_record/active_record/reactive_record/dummy_value.rb +236 -0
  42. data/lib/reactive_record/active_record/reactive_record/getters.rb +133 -0
  43. data/lib/reactive_record/active_record/reactive_record/isomorphic_base.rb +576 -0
  44. data/lib/reactive_record/active_record/reactive_record/lookup_tables.rb +54 -0
  45. data/lib/reactive_record/active_record/reactive_record/operations.rb +107 -0
  46. data/lib/reactive_record/active_record/reactive_record/scoped_collection.rb +62 -0
  47. data/lib/reactive_record/active_record/reactive_record/setters.rb +194 -0
  48. data/lib/reactive_record/active_record/reactive_record/unscoped_collection.rb +16 -0
  49. data/lib/reactive_record/active_record/reactive_record/while_loading.rb +343 -0
  50. data/lib/reactive_record/active_record_error.rb +4 -0
  51. data/lib/reactive_record/broadcast.rb +223 -0
  52. data/lib/reactive_record/engine.rb +11 -0
  53. data/lib/reactive_record/interval.rb +190 -0
  54. data/lib/reactive_record/permissions.rb +117 -0
  55. data/lib/reactive_record/pry.rb +13 -0
  56. data/lib/reactive_record/reactive_scope.rb +18 -0
  57. data/lib/reactive_record/scope_description.rb +121 -0
  58. data/lib/reactive_record/serializers.rb +7 -0
  59. data/lib/reactive_record/server_data_cache.rb +478 -0
  60. data/path_release_steps.md +9 -0
  61. metadata +399 -109
  62. data/CODE_OF_CONDUCT.md +0 -49
  63. data/examples/chat-app/.gitignore +0 -21
  64. data/examples/chat-app/Gemfile +0 -62
  65. data/examples/chat-app/Gemfile.lock +0 -309
  66. data/examples/chat-app/README.md +0 -3
  67. data/examples/chat-app/Rakefile +0 -6
  68. data/examples/chat-app/app/assets/config/manifest.js +0 -3
  69. data/examples/chat-app/app/assets/javascripts/application.js +0 -3
  70. data/examples/chat-app/app/assets/stylesheets/application.scss +0 -33
  71. data/examples/chat-app/app/controllers/application_controller.rb +0 -3
  72. data/examples/chat-app/app/controllers/home_controller.rb +0 -5
  73. data/examples/chat-app/app/hyperloop/components/app.rb +0 -12
  74. data/examples/chat-app/app/hyperloop/components/formatted_div.rb +0 -15
  75. data/examples/chat-app/app/hyperloop/components/input_box.rb +0 -26
  76. data/examples/chat-app/app/hyperloop/components/message.rb +0 -29
  77. data/examples/chat-app/app/hyperloop/components/messages.rb +0 -8
  78. data/examples/chat-app/app/hyperloop/components/nav.rb +0 -30
  79. data/examples/chat-app/app/hyperloop/models/application_record.rb +0 -3
  80. data/examples/chat-app/app/hyperloop/models/message.rb +0 -6
  81. data/examples/chat-app/app/hyperloop/operations/operations.rb +0 -13
  82. data/examples/chat-app/app/hyperloop/stores/message_store.rb +0 -17
  83. data/examples/chat-app/app/policies/application_policy.rb +0 -9
  84. data/examples/chat-app/app/views/layouts/application.html.erb +0 -12
  85. data/examples/chat-app/bin/bundle +0 -3
  86. data/examples/chat-app/bin/rails +0 -9
  87. data/examples/chat-app/bin/rake +0 -9
  88. data/examples/chat-app/bin/setup +0 -34
  89. data/examples/chat-app/bin/spring +0 -17
  90. data/examples/chat-app/bin/update +0 -29
  91. data/examples/chat-app/config.ru +0 -5
  92. data/examples/chat-app/config/application.rb +0 -12
  93. data/examples/chat-app/config/boot.rb +0 -3
  94. data/examples/chat-app/config/cable.yml +0 -9
  95. data/examples/chat-app/config/database.yml +0 -25
  96. data/examples/chat-app/config/environment.rb +0 -5
  97. data/examples/chat-app/config/environments/development.rb +0 -56
  98. data/examples/chat-app/config/environments/production.rb +0 -86
  99. data/examples/chat-app/config/environments/test.rb +0 -42
  100. data/examples/chat-app/config/initializers/application_controller_renderer.rb +0 -6
  101. data/examples/chat-app/config/initializers/assets.rb +0 -11
  102. data/examples/chat-app/config/initializers/backtrace_silencers.rb +0 -7
  103. data/examples/chat-app/config/initializers/cookies_serializer.rb +0 -5
  104. data/examples/chat-app/config/initializers/filter_parameter_logging.rb +0 -4
  105. data/examples/chat-app/config/initializers/hyperloop.rb +0 -6
  106. data/examples/chat-app/config/initializers/inflections.rb +0 -16
  107. data/examples/chat-app/config/initializers/mime_types.rb +0 -4
  108. data/examples/chat-app/config/initializers/new_framework_defaults.rb +0 -24
  109. data/examples/chat-app/config/initializers/session_store.rb +0 -3
  110. data/examples/chat-app/config/initializers/wrap_parameters.rb +0 -14
  111. data/examples/chat-app/config/locales/en.yml +0 -23
  112. data/examples/chat-app/config/puma.rb +0 -47
  113. data/examples/chat-app/config/routes.rb +0 -5
  114. data/examples/chat-app/config/secrets.yml +0 -22
  115. data/examples/chat-app/config/spring.rb +0 -6
  116. data/examples/chat-app/db/migrate/20170319194429_create_message.rb +0 -9
  117. data/examples/chat-app/db/schema.rb +0 -48
  118. data/examples/chat-app/db/seeds.rb +0 -7
  119. data/examples/chat-app/lib/assets/.keep +0 -0
  120. data/examples/chat-app/lib/tasks/.keep +0 -0
  121. data/examples/chat-app/log/.keep +0 -0
  122. data/examples/chat-app/public/404.html +0 -67
  123. data/examples/chat-app/public/422.html +0 -67
  124. data/examples/chat-app/public/500.html +0 -66
  125. data/examples/chat-app/public/apple-touch-icon-precomposed.png +0 -0
  126. data/examples/chat-app/public/apple-touch-icon.png +0 -0
  127. data/examples/chat-app/public/favicon.ico +0 -0
  128. data/examples/chat-app/public/robots.txt +0 -5
  129. data/examples/chat-app/test/controllers/.keep +0 -0
  130. data/examples/chat-app/test/fixtures/.keep +0 -0
  131. data/examples/chat-app/test/fixtures/files/.keep +0 -0
  132. data/examples/chat-app/test/helpers/.keep +0 -0
  133. data/examples/chat-app/test/integration/.keep +0 -0
  134. data/examples/chat-app/test/mailers/.keep +0 -0
  135. data/examples/chat-app/test/models/.keep +0 -0
  136. data/examples/chat-app/test/test_helper.rb +0 -10
  137. data/examples/chat-app/tmp/.keep +0 -0
  138. data/examples/chat-app/vendor/assets/javascripts/.keep +0 -0
  139. data/examples/chat-app/vendor/assets/stylesheets/.keep +0 -0
  140. data/lib/hyperloop/model/version.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1cd0a81127216e378636768fc0de1342ba85285a
4
- data.tar.gz: 6801d649c3f128ebe34ad3564af868a04341896c
2
+ SHA256:
3
+ metadata.gz: 239fd6331a899d54a2aee92ee89b9fcb2cdba2d5d515c5bc3df3e023c6d6897b
4
+ data.tar.gz: cfadd8422148a7d425c3a4e2fecf07ff0cc04aca4b8e7a6a98d3ac5c9bad579b
5
5
  SHA512:
6
- metadata.gz: 60f4dc1d0d6585a027f6e621b5df2d3c2b5f01a1b389e9a80d9d160194b9e8ed8bfc50d528e40b6db17a854f12c453cc935cd85485ebe1ff23358b76ed13d156
7
- data.tar.gz: ff589d922108151ac9e602aff2eeea735f95a9baf8bcbb1e1782b0c06cfdf0ce76f945f454821448ae207720b9ef881c645b1a8f645eb75f18e2680684f21a61
6
+ metadata.gz: 09189ba19dee4c270126de40d68fd209c9996895bdbb3537b037e58f3e4937639d7346e2e653ca2987b3bbc515fbbb1916395b2796bce54d68210b7b5a900a8c
7
+ data.tar.gz: 733a4eec762c3d68c61e5b666a473dd93e0ee82a417429d68d227c7ba1e2e6f3716b28a247434152c00d5a2681accc32eed2a841f91c3f8846e3bdf4c64a3b2a
data/.gitignore CHANGED
@@ -1,42 +1,36 @@
1
- *.rbc
2
- capybara-*.html
3
- .rspec
4
- /log
5
- /tmp
6
- /db/*.sqlite3
7
- /db/*.sqlite3-journal
8
- /public/system
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /.byebug_history
9
5
  /coverage/
10
- /spec/tmp
11
- **.orig
12
- rerun.txt
13
- pickle-email-*.html
14
-
15
- # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
16
- config/initializers/secret_token.rb
17
- config/secrets.yml
18
-
19
- # dotenv
20
- # TODO Comment out this rule if environment variables can be committed
21
- .env
22
-
23
- ## Environment normalization:
24
- /.bundle
25
- /vendor/bundle
26
-
27
- # these should all be checked in to normalize the environment:
28
- # Gemfile.lock, .ruby-version, .ruby-gemset
29
-
30
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
31
- .rvmrc
32
-
33
- # if using bower-rails ignore default bower_components path bower.json files
34
- /vendor/assets/bower_components
35
- *.bowerrc
36
- bower.json
37
-
38
- # Ignore pow environment settings
39
- .powenv
40
-
41
- # Ignore Byebug command history file.
42
- .byebug_history
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ tmp/
10
+ spec/test_app/tmp/
11
+ spec/test_app/db/test.sqlite3
12
+ spec/test_app/log/test.log
13
+ spec/test_app/log/development.log
14
+ spec/test_app/Gemfile.lock
15
+ /synchromesh-simple-poller-store
16
+ /synchromesh-pusher-channel-store
17
+ /examples/action-cable/rails_cache_dir/
18
+ rails_cache_dir/
19
+ react_prerendering_src.js
20
+
21
+ .bundle/
22
+ log/*.log
23
+ pkg/
24
+ reactive_record_test_app/db/*.sqlite3
25
+ reactive_record_test_app/log/
26
+ reactive_record_test_app/tmp/
27
+ reactive_record_test_app/.sass-cache
28
+ .DS_Store
29
+ public/assets/*
30
+
31
+ # ignore gems
32
+ *.gem
33
+
34
+ # ingore Idea
35
+ .idea
36
+ .vscode
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,33 @@
1
+ dist: trusty
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.4.4
6
+ - 2.5.1
7
+ - ruby-head
8
+ services:
9
+ - mysql
10
+ env:
11
+ - DRIVER=google-chrome TZ=Europe/Berlin
12
+ before_install:
13
+ - if [[ "$DRIVER" == "google-chrome" ]]; then wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -; fi
14
+ - if [[ "$DRIVER" == "google-chrome" ]]; then echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list; fi
15
+ - if [[ "$DRIVER" == "google-chrome" ]]; then sudo apt-get update -qq && sudo apt-get install -qq -y google-chrome-stable; fi
16
+ - sudo apt-get install -qq -y fonts-liberation
17
+ - gem install bundler
18
+ before_script:
19
+ - cd spec/test_app
20
+ - bundle install --jobs=3 --retry=3
21
+ - bundle exec rails db:setup
22
+ - cd ../../
23
+ - if [[ "$DRIVER" == "google-chrome" ]]; then chromedriver-update; fi
24
+ - if [[ "$DRIVER" == "google-chrome" ]]; then ls -lR ~/.chromedriver-helper/; fi
25
+ - if [[ "$DRIVER" == "google-chrome" ]]; then chromedriver --version; fi
26
+ - if [[ "$DRIVER" == "google-chrome" ]]; then google-chrome --version; fi
27
+ - if [[ "$DRIVER" == "google-chrome" ]]; then which chromedriver; fi
28
+ - if [[ "$DRIVER" == "google-chrome" ]]; then which google-chrome; fi
29
+ script: bundle exec rspec
30
+ gemfile:
31
+ - gemfiles/hyper-mesh.gemfile
32
+ matrix:
33
+ fast_finish: true
@@ -0,0 +1,34 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file starting with v0.8.4.
4
+ This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
+
6
+ Changes are grouped as follows:
7
+ - **Added** for new features.
8
+ - **Changed** for changes in existing functionality.
9
+ - **Deprecated** for once-stable features to be removed in upcoming releases.
10
+ - **Removed** for deprecated features removed in this release.
11
+ - **Fixed** for any bug fixes.
12
+ - **Security** to invite users to upgrade in case of vulnerabilities.
13
+
14
+ <!--
15
+ Whitespace conventions:
16
+ - 4 spaces before ## titles
17
+ - 2 spaces before ### titles
18
+ - 1 spaces before normal text
19
+ -->
20
+
21
+ ## [0.5.3] - 2017-01-03
22
+
23
+
24
+ ### Added
25
+
26
+ - Fixed problem with synchronizing multiple requests to same record within one render cycle (#20)
27
+ - Add *finder* methods. I.e. server side methods that return a single record using a custom query. (#12)
28
+ - Allow `save` even if records are loading (#10)
29
+ - `ReactiveRecord.Load` will automatically apply `.itself` to the final value of the load block (#9)
30
+
31
+
32
+ ### Fixed
33
+
34
+ - Can't create AR records from within Rake Tasks. (#20)
data/DOCS.md ADDED
@@ -0,0 +1,735 @@
1
+ # Hyperloop Models
2
+
3
+ Hyperloop **Models** are implemented in the **HyperModel Gem**.
4
+
5
+ In Hyperloop, your ActiveRecord Models are available in your Isomorphic code.
6
+
7
+ Components, Operations, and Stores have CRUD access to your server side ActiveRecord Models, using the standard ActiveRecord API.
8
+
9
+ In addition, Hyperloop implements push notifications (via a number of possible technologies) so changes to records on the server are dynamically pushed to all authorized clients.
10
+
11
+ In other words, one browser creates, updates, or destroys a Model, and the changes are persisted in ActiveRecord models and then broadcast to all other authorized clients.
12
+
13
+ + The `hyper-model` gem provides ActiveRecord Models to Hyperloop's Isomorphic architecture.
14
+ + You access your Model data in your Components, Operations, and Stores just like you would on the server or in an ERB or HAML view file.
15
+ + If an optional push transport is connected Hyperloop broadcasts any changes made to your ActiveRecord models as they are persisted on the server or updated by one of the authorized clients.
16
+ + Some Models can be designated as *server-only* which means they are not available to the Isomorphic code.
17
+
18
+ For example, consider a simple model called `Dictionary` which might be part of Wiktionary type app.
19
+
20
+ ```ruby
21
+ class Dictionary < ActiveRecord::Base
22
+
23
+ # attributes
24
+ # word: string
25
+ # definition: text
26
+ # pronunciation: string
27
+
28
+ scope :defined, -> { 'definition IS NOT NULL AND pronunciation IS NOT NULL' }
29
+ end
30
+ ```
31
+
32
+ Here is a very simple Hyperloop Component that shows a random word from the dictionary:
33
+
34
+ ```ruby
35
+ class WordOfTheDay < Hyperloop::Component
36
+
37
+ def pick_entry!
38
+ # pick a random word and assign the selected record to entry
39
+ @entry = Dictionary.defined.all[rand(Dictionary.defined.count)]
40
+ force_update! # redraw our component when the word changes
41
+ # Notice that we use standard ActiveRecord constructs to select our
42
+ # random entry value
43
+ end
44
+
45
+ # pick an initial entry before we mount our component...
46
+ before_mount :pick_entry
47
+
48
+ # Again in our render block we use the standard ActiveRecord API, such
49
+ # as the 'defined' scope, and the 'word', 'pronunciation', and
50
+ # 'definition' attribute getters.
51
+ render(DIV) do
52
+ DIV { "total definitions: #{Dictionary.defined.count}" }
53
+ DIV do
54
+ DIV { @entry.word }
55
+ DIV { @entry.pronunciation }
56
+ DIV { @entry.definition }
57
+ BUTTON { 'pick another' }.on(:click) { pick_entry! }
58
+ end
59
+ end
60
+ ```
61
+
62
+ For complete examples with *push* updates, see any of the apps in the `examples` directory, or build your own in 5 minutes following one of the quickstart guides:
63
+
64
+ ## Isomorphic Models
65
+
66
+ Depending on the architecture of your application, you may decide that some of your models should be Isomorphic and some should remain server-only. The consideration will be that your Isomorphic models will be compiled by Opal to JavaScript and accessible on he client (without the need for a boilerplate API) - Hyperloop takes care of the communication between your server-side models and their client-side compiled versions and you can use Policy to govern access to the models.
67
+
68
+ In order for Hyperloop to see your Models (and his make them Isomorphic) you need to move them to the `hyperloop/models` folder. Only models in this folder will be seen by Hyperloop and compiled to Javascript. Once a Model is on this folder it ill be accessable to both your client and server code.
69
+
70
+ | **Location of Models** | **Scope** |
71
+ | ------------------------- |---------------|
72
+ | `app\models` | Server-side code only |
73
+ | `app\hyperloop\models` | Isomorphic code (client and server) |
74
+
75
+ ### Rails 5.1.x
76
+
77
+ Upto Rails 4.2, all models inherited from `ActiveRecord::Base`. But starting from Rails 5, all models will inherit from `ApplicationRecord`.
78
+
79
+ To accommodate this change, the following file has been automatically added to models in Rails 5 applications.
80
+
81
+ ```ruby
82
+ # app/models/application_record.rb
83
+ class ApplicationRecord < ActiveRecord::Base
84
+ self.abstract_class = true
85
+ end
86
+ ```
87
+
88
+ For Hyperloop to see this change, this file needs to be moved (or copied if you have some server-side models) to the `apps/hyperloop` folder.
89
+
90
+ ### Explicit Scope Access
91
+
92
+ In order to prevent unauthorized access to information like scope counts, lists of record ids, etc, Hyperloop now (see issue https://github.com/ruby-hyperloop/hyper-mesh/issues/43) requires you explicitly allow scopes to be viewed on the client, otherwise you will get an AccessViolation.
93
+
94
+ To globally allow access to all scopes add this to the ApplicationRecord class
95
+
96
+ ```ruby
97
+ class ApplicationRecord < ActiveRecord::Base
98
+ regulate_scope :all
99
+ end
100
+ ```
101
+
102
+ ## ActiveRecord API
103
+
104
+ Hyperloop uses a subset of the standard ActiveRecord API to give your Isomorphic Components, Operations and Stores access to your server side Models. As much as possible Hyperloop follows the syntax and semantics of ActiveRecord.
105
+
106
+ ### Interfacing to React
107
+
108
+ Hyperloop integrates with React (through Components) to deliver your Model data to the client without you having to create extra APIs or specialized controllers. The key idea of React is that when state (or params) change, the portions of the display effected by this data will be updated.
109
+
110
+ Hyperloop automatically creates React state objects that will be updated as server side data is loaded or changes. When these states change the associated parts of the display will be updated.
111
+
112
+ A brief overview of how this works will help you understand the how Hypeloop gets the job done.
113
+
114
+ #### Rendering Cycle
115
+
116
+ On the UI you will be reading models in order to display data.
117
+
118
+ If during the rendering of the display the Model data is not yet loaded, placeholder values (the default values from the `columns_hash`) will be returned by Hyperloop.
119
+
120
+ Hyperloop then keeps track of where these placeholders (or `DummyValue`s) are displayed, and when they do get loaded, those parts of the display will re-render.
121
+
122
+ If later the data changes (either due to local user actions, or receiving push updates) then again any parts of the display that were dependent on the current values will be re-rendered.
123
+
124
+ You normally do not have to be aware of this. Just access your Models using the normal scopes and finders, then compute values and display attributes as you would on the server. Initially the display will show the placeholder values and then will be replaced with the real values.
125
+
126
+ #### Prerendering
127
+
128
+ During server-side pre-rendering, Hyperloop has direct access to the server so on initial page load all the values will be loaded and present.
129
+
130
+ #### Lazy Loading
131
+
132
+ Hyperloop lazy loads values, and does not load any thing until an explicit displayable value is requested. For example `Todo.all` will have no action, but `Todo.all.pluck[:title]` will return an array of titles.
133
+
134
+ At the end of the rendering cycle the set of all values requested will be merged into a tree structure and sent to the server, returning the minimum amount of data needed.
135
+
136
+ #### Load Cycle Methods
137
+
138
+ There are a number of methods that allow you to interact with this load cycle when needed. These are documented [below](#other-methods-for-interacting-with-the-load-and-render-cycle).
139
+
140
+ ### Class Methods
141
+
142
+ #### New and Create
143
+
144
+ `new`: Takes a hash of attributes and initializes a new unsaved record. The values of any attributes not specified in the hash will be taken from the Models default values specified in the `columns_hash`.
145
+
146
+ If `new` is passed a native javascript object it will be treated as a hash and converted accordingly.
147
+
148
+ `create`: Short hand for `new(...).save`. See the `save` instance method for details on how saving is done.
149
+
150
+ #### Scoping and Finding
151
+
152
+ `scope` and `default_scope`: Hyperloop adds four new options to these methods: `joins`, `client`, `select` and `server`. The `joins` option provides information on how the scope will be joined with other models. The `client` and `select` options allow scoping to be done on the client side to offload this from the server, and the `server` option is there just for symmetry with the other options.
153
+
154
+ ```ruby
155
+ # the active scope proc is executed on the server
156
+ scope :active, -> () { where(completed: true) }
157
+
158
+ # if the scope does a join (or include) this must be indicated
159
+ # using the joins: option.
160
+ scope :with_recent_comments,
161
+ -> { joins(:comments).where('comment.created_at >= ?', Time.now-1.week) },
162
+ joins: ['comments'] # or joins: 'comments'
163
+
164
+ # the server side proc can be indicated by the server: option
165
+ # an optional client side proc can be provided to compute the scope
166
+ # locally at the client
167
+ scope :completed,
168
+ server: -> { where(complete: true) }
169
+ client: -> { complete } # return true if the record should be included
170
+ ```
171
+
172
+ `unscoped` and `all`: These builtin scopes work just like standard ActiveRecord.
173
+
174
+ ```ruby
175
+ Word.all.each { |word| LI { word.text }}
176
+ ```
177
+
178
+ BTW: to save typing you can skip the `all`: Models will respond like enumerators.
179
+
180
+ `find`: takes an id and delivers the corresponding record.
181
+
182
+ `find_by`: takes a single item hash indicating an attribute value pair to find.
183
+
184
+ `find_by_...`: i.e. `find_by_first_name` these methods will find the first record with a matching attribute.
185
+
186
+ ```ruby
187
+ Word.find_by_text('hello') # short for Word.find_by(text: 'hello')
188
+ ```
189
+
190
+ `limit` and `offset`: These builtin scopes behave as they do on the server:
191
+
192
+ ```ruby
193
+ Word.offset(500).limit(20) # get words 500-519
194
+ ```
195
+
196
+ #### Relationships and Aggregations
197
+
198
+ `belongs_to, has_many, has_one`: These all work as on the server. **However it is important that you fully specify both sides of the relationship.**
199
+
200
+ ```ruby
201
+ class Todo < ActiveRecord::Base
202
+ belongs_to :assigned_to, class_name: 'User'
203
+ end
204
+
205
+ class User < ActiveRecord::Base
206
+ has_many :todos, foreign_key: 'assigned_to_id'
207
+ end
208
+ ```
209
+
210
+ Note that on the client the linkages between relationships are live and direct. In the above example this works:
211
+
212
+ ```ruby
213
+ Todo.create(assigned_to: some_user)
214
+ ```
215
+
216
+ but this may not:
217
+
218
+ ```ruby
219
+ Todo.create(assigned_to_id: some_user.id)
220
+ ```
221
+
222
+ `composed_of`: You can create aggregate models like ActiveRecord.
223
+
224
+ Similar to the linkages in relationships, aggregate records are represented on the client as actual independent objects.
225
+
226
+ #### Defining server methods
227
+
228
+ Normally an application defined instance method will run on the client and the server:
229
+
230
+ ```ruby
231
+ class User < ActiveRecord::Base
232
+ def full_name
233
+ "#{first_name} #{last_name}"
234
+ end
235
+ end
236
+ ```
237
+
238
+ Sometimes it is desirable to only run the method on the server. This can be done using the `server_method` macro:
239
+
240
+ ```ruby
241
+ class User < ActiveRecord::Base
242
+ server_method :full_name, default: '' do
243
+ "#{first_name} #{last_name}"
244
+ end
245
+ end
246
+ ```
247
+
248
+ When the method is first called on the client the default value will be returned, and there will be a reactive update when the true value is returned from the server.
249
+
250
+ To force the value to be recomputed at the server append a `!` to the end of the name, otherwise the last value returned from the server will continue to be returned.
251
+
252
+ #### Model Information
253
+
254
+ `column_names`: returns a list of the database columns.
255
+
256
+ `columns_hash`: returns the details of the columns specification. Note that on the server `columns_hash` returns a hash of objects specifying column information. On the client the entire structure is just one big hash of hashes.
257
+
258
+ `abstract_class=`, `abstract_class?`, `primary_key`, `primary_key=`, `inheritance_column`, `inheritance_column=`, `model_name`: All work as on the server. See ActiveRecord documentation for more info.
259
+
260
+ ### Instance Methods
261
+
262
+ #### Attribute and Relationship Getter and Setters
263
+
264
+ All attributes have an associated getter and setter. All relationships have a getter. All `belongs_to` relationships also have a setter. `has_many` relationships can be updated using the push (`<<`) operator or using the `delete` method.
265
+
266
+ ```ruby
267
+ puts my_todo.title
268
+ my_todo.title = "neutitle"
269
+ my_todo.comments << a_new_comment
270
+ a_new_comment.todo == my_todo # true!
271
+ ```
272
+
273
+ In addition if the attribute getter ends with a bang (!) then this will force a fetch of the attribute from the server. This is typically not necessary if push updates are configured.
274
+
275
+ #### Saving
276
+
277
+ The `save` method works like ActiveRecord save, *except* it returns a promise that is resolved when the save completes (or fails.)
278
+
279
+ ```ruby
280
+ my_todo.save(validate: false).then do |result|
281
+ # result is a hash with {success: ..., message: , models: ....}
282
+ end
283
+ ```
284
+
285
+ After a save operation completes the models will have an `errors` hash (just like on the server) with any validation problems.
286
+
287
+ During the save operation the method `saving?` will return `true`. This can be used to instead of (or with) the promise to update the screen:
288
+
289
+ ```ruby
290
+ render do
291
+ ...
292
+ if some_model.saving?
293
+ ... display please wait ...
294
+ elsif some_model.errors.any?
295
+ ... highlight the errors ...
296
+ else
297
+ ... display data ...
298
+ end
299
+ ...
300
+ end
301
+ ```
302
+
303
+ #### Destroy
304
+
305
+ Like `save` destroy returns a promise that is resolved when the destroy completes.
306
+
307
+ After the destroy completes the record's `destroyed?` method will return true.
308
+
309
+ #### Other Instance Methods
310
+
311
+ `new?` returns true if the model is new and not yet saved.
312
+
313
+ `primary_key` returns the primary key for the model
314
+
315
+ `id` returns the value of the primary key for this instance
316
+
317
+ `model_name` returns the model_name.
318
+
319
+ `revert` Undoes any unsaved changes to the instance.
320
+
321
+ `changed?` returns true if any attributes have changed (always true for a new model)
322
+
323
+ `dup` duplicate the instance.
324
+
325
+ `==` two instances are the same if it is known that they reference the same underlying table row.
326
+
327
+ `..._changed?` (i.e. name_changed?) returns true if the specific attribute has changed.
328
+
329
+ `itself` returns the record, but will override lazy loading and force a load of at least the model's id.
330
+
331
+ ### Load and Render Cycle
332
+
333
+ #### loading? and loaded?
334
+
335
+ All Ruby objects will respond to these methods. If you want to put up a "Please Wait" message, spinner, etc, you can use the `loaded?` or `loading?` method to determine if the object represents a real loaded value or not. Any value for which `loaded?` returns `false` (or `loading?` returns `true`) will eventually load and cause a re-render
336
+
337
+ #### Hyperloop::Model.load method
338
+
339
+ Sometimes it is necessary to insure values are loaded outside of the rendering cycle. For this you can use the `Hyperloop::Model.load` method:
340
+
341
+ ```ruby
342
+ Hyperloop::Model.load do
343
+ x = my_model.some_attribute
344
+ OtherModel.find(x+12).other_attribute
345
+ # code in here can be arbitrarily complex and load
346
+ # will re-execute it until all values are loaded
347
+ # the final expression is passed to the promise
348
+ end.then |result|
349
+ puts result
350
+ end
351
+ ```
352
+
353
+ #### Force Loading Attributes
354
+
355
+ Normally you will simply display attributes as part of the render method, and when the values are loaded from the server the component will re-render.
356
+
357
+ Sometimes outside of the render method you may need to insure an attribute (or a server side method) is loaded before proceeding. This is typically when you are building some kind of higher level store.
358
+
359
+ The `load` method takes a list of attributes (symbols) and will insure these are loaded. Load returns a promise that is resolved when the load completes, or can be passed a block that will execute when the load completes.
360
+
361
+ ```ruby
362
+ before_mount do
363
+ Todo.find(1).load(:name).then do |name|
364
+ @name = name;
365
+ state.loaded! true
366
+ end
367
+ end
368
+ ```
369
+
370
+ Think hard about how you are using this, as Hyperloop already acts as flux store, and is managing state for you. It may be you are just creating a redundant store!
371
+
372
+ ## Client Side Scoping
373
+
374
+ By default scopes will be recalculated on the server. For simple scopes that do not use joins or includes no additional action needs to be taken to make scopes work with Hyperloop. For scopes that do use joins, or if you want to offload the scoping computation from the server to the client read this section.
375
+
376
+ ## ActiveRecord Scope Enhancement
377
+
378
+ When the client receives notification that a record has changed Hyperloop finds the set of currently rendered scopes that might be effected, and requests them to be updated from the server.
379
+
380
+ On the server scopes are a useful way to structure code. **On the client** scopes are vital as they limit the amount of data loaded, viewed, and updated in the browser. Consider a factory floor management system that shows *job* state as work flows through the factory. There may be millions of jobs that a production floor browser is authorized to view, but at any time there are probably only 50 being shown. Using ActiveRecord scopes is the way Hyperloop keeps the data requested by the browser limited to a reasonable amount.
381
+
382
+ To make scopes work efficiently on the client Hyperloop adds some features to the ActiveRecord `scope` and `default_scope` macros. Note you must use the `scope` macro (and not class methods) for things to work with Hyperloop.
383
+
384
+ The additional features are accessed via the `:joins`, `:client`, and `:select` options.
385
+
386
+ The `:joins` option tells the Hyperloop client which models are joined with the scope. *You must add a `:joins` option if the scope has any data base join operations in it, otherwise if a joined model changes, Hyperloop will not know to update the scope.*
387
+
388
+ The `:client` and `:select` options provide the client a way to update scopes without having to contact the server. Unlike the `:joins` option this is an optimization and is not required for scopes to work.
389
+
390
+ ```ruby
391
+ class Todo < ActiveRecord::Base
392
+
393
+ # Standard ActiveRecord form:
394
+ # the proc will be evaluated as normal on the server, and as needed updates
395
+ # will be requested from the clients
396
+
397
+ scope :active, -> () { where(completed: true) }
398
+
399
+ # In the simple form the scope will be reevaluated if the model that is
400
+ # being scoped changes, and if the scope is currently being used to render data.
401
+
402
+ # If the scope joins with other data you will need to specify this by
403
+ # passing a relationship or array of relationships to the `joins` option.
404
+
405
+ scope :with_recent_comments,
406
+ -> { joins(:comments).where('comment.created_at >= ?', Time.now-1.week) },
407
+ joins: ['comments'] # or joins: 'comments'
408
+
409
+ # Now with_recent_comments will be re-evaluated whenever a Todo record, or a Comment
410
+ # joined with a Todo change.
411
+
412
+ # Normally whenever Hyperloop detects that a scope may be effected by a changed
413
+ # model, it will request the scope be re-evaluated on the server. To offload this
414
+ # computation to the client provide a client side scope method:
415
+
416
+ scope :with_recent_comments,
417
+ -> { joins(:comments).where('comment.created_at >= ?', Time.now-1.week) },
418
+ joins: ['comments']
419
+ client: -> { comments.detect { |comment| comment.created_at >= Time.now-1.week }
420
+
421
+ # The client proc is executed on each candidate record, and if it returns true the record
422
+ # will be added to the scope.
423
+
424
+ # Instead of a client proc you can provide a select proc, which will receive the entire
425
+ # collection which can then be filtered and sorted.
426
+
427
+ scope :sort_by_created_at,
428
+ -> { order('created_at DESC') }
429
+ select: -> { sort { |a, b| b.created_at <=> a.created_at }}
430
+
431
+ # To keep things tidy you can specify the server scope proc with the :server option
432
+
433
+ scope :completed,
434
+ server: -> { where(complete: true) }
435
+ client: -> { complete }
436
+
437
+ # The expressions in the joins array can be arbitrary sequences of relationships and
438
+ # scopes such as 'comments.author'.
439
+
440
+ scope :with_managers_comments,
441
+ server: -> { ... }
442
+ joins: ['comments.author', 'owner']
443
+ client: -> { comments.detect { |comment| comment.author == owner.manager }}}
444
+
445
+ # You can also use the client, select, server, and joins option with the default_scope macro
446
+
447
+ default_scope server: -> { where(deleted: false).order('updated_at DESC') }
448
+ select: -> { select { |r| !r.deleted }.sort { |a, b| b <=> a } }
449
+
450
+ # NOTE: it is highly recommend to provide a client proc with default_scopes. Otherwise
451
+ # every change is going to require a server interaction regardless of what other client procs
452
+ # you provide.
453
+
454
+ end
455
+ ```
456
+
457
+ #### How it works
458
+
459
+ Consider this scope on the Todo model
460
+
461
+ ```ruby
462
+ scope :with_managers_comments,
463
+ server: -> { joins(owner: :manager, comments: :author).where('managers_users.id = authors_comments.id').distinct },
464
+ client: -> { comments.detect { |comment| comment.author == owner.manager }}
465
+ joins: ['comments.author', 'owner']
466
+ ```
467
+
468
+ The joins 'comments.author' relationship is inverted so that we have User 'has_many' Comments which 'belongs_to' Todos.
469
+
470
+ Thus we now know that whenever a User or a Comment changes this may effect our with_managers_comments scope
471
+
472
+ Likewise 'owner' becomes User 'has_many' Todos.
473
+
474
+ Lets say that a user changes teams and now has a new manager. This means according to the relationships that the
475
+ User model will change (i.e. there will be a new manager_id in the User model) and thus all Todos belonging to that
476
+ User are subject to evaluation.
477
+
478
+ While the server side proc efficiently delivers all the objects in the scope, the client side proc just needs to incrementally update the scope.
479
+
480
+ ## Configuring the Transport
481
+
482
+ Hyperloop implements push notifications (via a number of possible technologies) so changes to records on the server are dynamically pushed to all authorized clients.
483
+
484
+ The can be accomplished by configuring **one** of the push technologies below:
485
+
486
+ | Push Technology | When to choose this... |
487
+ |---------------------------|--------------------|
488
+ | [Simple Polling](#setting-up-simple-polling) | The easiest push transport is the built-in simple poller. This is great for demos or trying out Hyperloop but because it is constantly polling it is not suitable for production systems or any kind of real debug or test activities. |
489
+ | [Action Cable](#setting-up-action-cable) | If you are using Rails 5 this is the perfect route to go. Action Cable is a production ready transport built into Rails 5. |
490
+ | [Pusher.com](#setting-up-pusher-com) | Pusher.com is a commercial push notification service with a free basic offering. The technology works well but does require a connection to the internet at all times. |
491
+ | [Pusher Fake](#setting-up-pusher-fake) | The Pusher-Fake gem will provide a transport using the same protocol as pusher.com but you can use it to locally test an app that will be put into production using pusher.com. |
492
+
493
+ ### Setting up Simple Polling
494
+
495
+ The easiest push transport is the built-in simple poller. This is great for demos or trying out Hyperloop but because it is constantly polling it is not suitable for production systems or any kind of real debug or test activities.
496
+
497
+ Simply add this initializer:
498
+
499
+ ```ruby
500
+ #config/initializers/hyperloop.rb
501
+ Hyperloop.configuration do |config|
502
+ config.transport = :simple_poller
503
+ # options
504
+ # config.opts = {
505
+ # seconds_between_poll: 5, # default is 0.5 you may need to increase if testing with Selenium
506
+ # seconds_polled_data_will_be_retained: 1.hour # clears channel data after this time, default is 5 minutes
507
+ # }
508
+ end
509
+ ```
510
+
511
+ That's it. Hyperloop will use simple polling for the push transport.
512
+
513
+ --------------------
514
+
515
+ ### Setting up Action Cable
516
+
517
+ To configure Hyperloop to use Action Cable, add this initializer:
518
+
519
+ ```ruby
520
+ #config/initializers/hyperloop.rb
521
+ Hyperloop.configuration do |config|
522
+ config.transport = :action_cable
523
+ end
524
+ ```
525
+
526
+ If you are already using ActionCable in your app that is fine, as Hyperloop will not interfere with your existing connections.
527
+
528
+ **Otherwise** go through the following steps to setup ActionCable.
529
+
530
+ Firstly, make sure the `action_cable` js file is required in your assets.
531
+
532
+ Typically `app/assets/javascripts/application.js` will finish with a `require_tree .` and this will pull in the `cable.js` file which will pull in `action_cable.js`
533
+
534
+ However at a minimum if `application.js` simply does a `require action_cable` that will be sufficient for Hyperloop.
535
+
536
+ Make sure you have a cable.yml file:
537
+
538
+ ```yml
539
+ # config/cable.yml
540
+ development:
541
+ adapter: async
542
+
543
+ test:
544
+ adapter: async
545
+
546
+ production:
547
+ adapter: redis
548
+ url: redis://localhost:6379/1
549
+ ```
550
+
551
+ Set allowed request origins (optional):
552
+
553
+ **By default action cable will only allow connections from localhost:3000 in development.** If you are going to something other than localhost:3000 you need to add something like this to your config:
554
+
555
+ ```ruby
556
+ # config/environments/development.rb
557
+ Rails.application.configure do
558
+ config.action_cable.allowed_request_origins = ['http://localhost:3000', 'http://localhost:5000']
559
+ end
560
+ ```
561
+
562
+ That's it. Hyperloop will use Action Cable as the push transport.
563
+
564
+ ----------------
565
+
566
+ ### Setting up Pusher.com
567
+
568
+ [Pusher.com](https://pusher.com/) provides a production ready push transport for your App. You can combine this with [Pusher-Fake](/docs/pusher_faker_quickstart.md) for local testing as well. You can get a free pusher account and API keys at [https://pusher.com](https://pusher.com)
569
+
570
+ First add the Pusher and HyperLoop gems to your Rails app:
571
+
572
+ add `gem 'pusher'` to your Gemfile.
573
+
574
+ Next Add the pusher js file to your application.js file:
575
+
576
+ ```ruby
577
+ # app/assets/javascript/application.js
578
+ ...
579
+ //= require 'hyperloop/pusher'
580
+ //= require_tree .
581
+ ```
582
+
583
+ Finally set the transport:
584
+
585
+ ```ruby
586
+ # config/initializers/Hyperloop.rb
587
+ Hyperloop.configuration do |config|
588
+ config.transport = :pusher
589
+ config.channel_prefix = "Hyperloop"
590
+ config.opts = {
591
+ app_id: "2....9",
592
+ key: "f.....g",
593
+ secret: "1.......3"
594
+ }
595
+ end
596
+ ```
597
+
598
+ That's it. You should be all set for push notifications using Pusher.com.
599
+
600
+ -------------------------
601
+ ### Setting up Pusher Fake
602
+
603
+ The [Pusher-Fake](https://github.com/tristandunn/pusher-fake) gem will provide a transport using the same protocol as pusher.com. You can use it to locally test an app that will be put into production using pusher.com.
604
+
605
+ Firstly add the Pusher, Pusher-Fake and HyperLoop gems to your Rails app
606
+
607
+ - add `gem 'pusher'` to your Gemfile.
608
+ - add `gem 'pusher-fake'` to the development and test sections of your Gemfile.
609
+
610
+ Next add the pusher js file to your application.js file
611
+
612
+ ```ruby
613
+ # app/assets/javascript/application.js
614
+ ...
615
+ //= require 'hyperloop/pusher'
616
+ //= require_tree .
617
+ ```
618
+
619
+ Add this initializer to set the transport:
620
+
621
+ ```ruby
622
+ # typically app/config/initializers/Hyperloop.rb
623
+ # or you can do a similar setup in your tests (see this gem's specs)
624
+ require 'pusher'
625
+ require 'pusher-fake'
626
+ # Assign any values to the Pusher app_id, key, and secret config values.
627
+ # These can be fake values or the real values for your pusher account.
628
+ Pusher.app_id = "MY_TEST_ID" # you use the real or fake values
629
+ Pusher.key = "MY_TEST_KEY"
630
+ Pusher.secret = "MY_TEST_SECRET"
631
+ # The next line actually starts the pusher-fake server (see the Pusher-Fake readme for details.)
632
+ # it is important this require be AFTER the above settings, as it will use these
633
+ require 'pusher-fake/support/base' # if using pusher with rspec change this to pusher-fake/support/rspec
634
+ # now copy over the credentials, and merge with PusherFake's config details
635
+ Hyperloop.configuration do |config|
636
+ config.transport = :pusher
637
+ config.channel_prefix = "Hyperloop"
638
+ config.opts = {
639
+ app_id: Pusher.app_id,
640
+ key: Pusher.key,
641
+ secret: Pusher.secret
642
+ }.merge(PusherFake.configuration.web_options)
643
+ end
644
+ ```
645
+
646
+ That's it. You should be all set for push notifications using Pusher Fake.
647
+
648
+ ## Debugging
649
+
650
+ Sometimes you need to figure out what connections are available, or what attributes are readable etc.
651
+
652
+ Its usually all to do with your policies, but perhaps you just need a little investigation.
653
+
654
+ TODO check rr has become hyperloop (as below)
655
+
656
+ You can bring up a console within the controller context by browsing `localhost:3000/hyperloop/console`
657
+
658
+ **Note: change `rr` to wherever you are mounting Hyperloop in your routes file.**
659
+
660
+ **Note: in rails 4, you will need to add the gem 'web-console' to your development section**
661
+
662
+ Within the context you have access to `session.id` and current `acting_user` which you will need, plus some helper methods to reduce typing
663
+
664
+ - Getting auto connection channels:
665
+ `channels(session_id = session.id, user = acting_user)`
666
+ e.g. `channels` returns all channels connecting to this session and user providing nil as the acting_user will test if connections can be made without there being a logged in user.
667
+
668
+ - Can a specific class connection be made:
669
+ `can_connect?(channel, user = acting_user)`
670
+ e.g. `can_connect? Todo` returns true if current acting_user can connect to the Todo class. You can also provide the class name as a string.
671
+
672
+ - Can a specific instance connection be made:
673
+ `can_connect?(channel, user = acting_user)`
674
+ e.g. `can_connect? Todo.first` returns true if current acting_user can connect to the first Todo Model. You can also provide the instance in the form 'Todo-123'
675
+
676
+ - What attributes are accessible for a Model instance:
677
+ `viewable_attributes(instance, user = acting_user)`
678
+
679
+ - Can the attribute be viewed:
680
+ `view_permitted?(instance, attribute, user = acting_user)`
681
+
682
+ - Can a Model be created/updated/destroyed:
683
+ `create_permitted?(instance, user = acting_user)`
684
+ e.g. `create_permitted?(Todo.new, nil)` can anybody save a new todo?
685
+ e.g. `destroy_permitted?(Todo.last)` can the acting_user destroy the last Todo
686
+
687
+ You can of course simulate server side changes to your Models through this console like any other console. For example
688
+
689
+ `Todo.new.save` will broadcast the changes to the Todo Model to any authorized channels.
690
+
691
+ ## Common Errors
692
+
693
+ - **No policy class**
694
+ If you don't define a policy file, nothing will happen because nothing will get connected. By default Hyperloop will look for a `ApplicationPolicy` class.
695
+
696
+ - **Wrong version of pusher-fake** (pusher-fake/base vs. pusher-fake/rspec) See the Pusher-Fake gem repo for details.
697
+
698
+ - Forgetting to add `require pusher` in application.js file
699
+ this results in an error like this:
700
+ ```text
701
+ Exception raised while rendering #<TopLevelRailsComponent:0x53e>
702
+ ReferenceError: Pusher is not defined
703
+ ```
704
+ To resolve make sure you `require 'pusher'` in your application.js file if using pusher. DO NOT require pusher from your components manifest as this will cause prerendering to fail.
705
+
706
+ - **No create/update/destroy policies**
707
+ You must explicitly allow changes to the Models to be made by the client. If you don't you will see 500 responses from the server when you try to update. To open all access do this in your application policy: `allow_change(to: :all, on: [:create, :update, :destroy]) { true }`
708
+
709
+ - **Cannot connect to real pusher account**
710
+ If you are trying to use a real pusher account (not pusher-fake) but see errors like this
711
+ ```text
712
+ pusher.self.js?body=1:62 WebSocket connection to
713
+ 'wss://127.0.0.1/app/PUSHER_API_KEY?protocol=7&client=js&version=3.0.0&flash=false'
714
+ failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
715
+ ```
716
+ Check to see if you are including the pusher-fake gem.
717
+ Hyperloop will always try to use pusher-fake if it sees the gem included. Remove it and you should be good to go. See [issue #5](https://github.com/hyper-react/HyperMesh/issues/5) for more details.
718
+
719
+ - **Cannot connect with ActionCable.**
720
+ Make sure that `config.action_cable.allowed_request_origins` includes the url you use for development (including the port) and that you are using `Puma`.
721
+
722
+ - **Attributes are not being converted from strings, or do not have their default values**
723
+ Eager loading is probably turned off. Hyperloop needs to eager load `hyperloop/models` so it can find all the column information for all Isomorphic models.
724
+
725
+ - **When starting rails you get a message on the rails console `couldn't find file 'browser'`**
726
+ The `hyper-component` v0.10.0 gem removed the dependency on opal-browser. You will have to add the 'opal-browser' gem to your Gemfile.
727
+
728
+ - **On page load you get a message about super class mismatch for `DummyValue`**
729
+ You are still have the old `reactive-record` gem in your Gemfile, remove it from your gemfile and your components manifest.
730
+
731
+ - **On page load you get a message about no method `session` for `nil`**
732
+ You are still referencing the old reactive-ruby or reactrb gems either directly or indirectly though a gem like reactrb-router. Replace any gems like `reactrb-router` with `hyper-router`. You can also just remove `reactrb`, as `hyper-model` will be included by the `hyper-model` gem.
733
+
734
+ - **You keep seeing the message `WebSocket connection to 'ws://localhost:3000/cable' failed: WebSocket is closed before the connection is established.`** every few seconds in the console.
735
+ There are probably lots of reasons for this, but it means ActionCable can't get itself going. One reason is that you are trying to run with Passenger instead of Puma, and trying to use `async` mode in cable.yml file. `async` mode requires Puma.