These are chat archives for opal/opal

Aug 2016
Ben Oakes
Aug 11 2016 01:27
Hey all, I saw YAML was removed from the standard library. Is there any good option (say, a pure Ruby gem) for client-side use? I'd like to use YAML over JSON, just because it's easier to type by hand...
I wasn't finding much when I searched...
Mitch VanDuyn
Aug 11 2016 02:56
just tried minimizing, gzipping, and running the reactrb todo demo app in production.
i had to change require_tree './public' to be an explicit require... anybody know any problems with require_tree during assets precompilation?
the structure of the app is standard reactrb:

components.rb looks like:

# app/views/components.rb
require 'opal'
require 'reactive-ruby'
require 'react'
if React::IsomorphicHelpers.on_opal_client?
  require 'opal-jquery'
  require 'browser'
  require 'browser/interval'
  require 'browser/delay'
  # add any additional requires that can ONLY run on client here
require 'reactive-router'
require 'react_router'
require 'reactive-record'
require 'synchromesh'
require '_react_public_models'
require_tree './components'

_react_public_models.rb looks like:

# app/models/_react_public_models.rb
require_tree './public'
Mitch VanDuyn
Aug 11 2016 03:05
this structure works just fine in development, but when I precompile, and run as a production server I get this error:
...rubydev/todo-tutorial/app/models/_react_public_models.rb:2:in `<top (required)>': undefined method `require_tree' for main:Object (NoMethodError)
Did you mean?  require_relative
Mitch VanDuyn
Aug 11 2016 03:31
but if I explicitly require the files in _react_public_models.rb (i.e. just do a require 'public/todo') all is well...
Mitch VanDuyn
Aug 11 2016 03:45
strangely enough I can't make it work even if require '_react_public_models.rb'
the views directory is added to the asset pipeline in the reactrb gem like so:
    class Railtie < ::Rails::Railtie
      config.before_configuration do |app|
        app.config.assets.enabled = true
        app.config.assets.paths << ::Rails.root.join('app', 'views').to_s

while the model path is added in application.rb like so:

module TodoTutorial
  class Application < Rails::Application
    config.assets.paths << ::Rails.root.join('app', 'models').to_s

looks pretty much the same to me...

Mitch VanDuyn
Aug 11 2016 03:53
using config.before_configuration had no effect.. btw...