These are chat archives for opal/opal

30th
May 2016
chewedon
@chewedon
May 30 2016 14:12
Hi...
So...Opal is a compiler for Ruby to Javascript ?
Austin Erlandson
@erlandsona
May 30 2016 14:14
@chewedon yup!
chewedon
@chewedon
May 30 2016 14:14
Do people use it to build SPA using Ruby?
because I don't really like Javascript
Elia Schito
@elia
May 30 2016 14:19
@chewedon yes, that's what it's for
chewedon
@chewedon
May 30 2016 14:20
I'm kinda expecting some sort of framework to generate project, arrange files into folders, models, views, controllers...
Elia Schito
@elia
May 30 2016 14:21
Opal is more like ruby the language, if you want something like, say, rails or sinatra for JS
that have a look at react.rb / clearwaterrb / inesita / lissio
chewedon
@chewedon
May 30 2016 14:21
Threre is Volt framework but that's isomorphic.
Elia Schito
@elia
May 30 2016 14:21
and voltframwork
yep
chewedon
@chewedon
May 30 2016 14:22
React.rb aye? haven't heard of that.
enjoy :)
chewedon
@chewedon
May 30 2016 14:23
Hey hey hey :)
And they all use Opal aye?
Elia Schito
@elia
May 30 2016 14:23
yep
chewedon
@chewedon
May 30 2016 14:24
I like it!.
:D
Aye...does React Ruby need Rails to work?
I thought it was standalone frontend thing ?
I'm using Rails 5 API mode to build a REST API for mobile applications.
Elia Schito
@elia
May 30 2016 14:27
@chewedon I'm not using it on any project so far, so I'm not sure cc @catmando @fkchang @jgaskins
Mitch VanDuyn
@catmando
May 30 2016 14:30
@chewedon nope
chewedon
@chewedon
May 30 2016 14:31
@catmando the Opal documentation seems to suggest adding React Ruby as part of the rails gem.
Mitch VanDuyn
@catmando
May 30 2016 14:31
React.rb can go anywhere from a cdn download with no frame work at all all the way to full rails integration with isomorphic models using the reactive-record gem
In the docs of reactrb.org there is a complete chat example with no framework
chewedon
@chewedon
May 30 2016 14:34
@elia Inesita looks cool :D
@elia oh, you made Vienna ? :D
Elia Schito
@elia
May 30 2016 14:36
no, it's by the original opal author: Adam Beynon
chewedon
@chewedon
May 30 2016 14:36
oh no...my mistake
Elia Schito
@elia
May 30 2016 14:36
np
: )
chewedon
@chewedon
May 30 2016 14:36
you contributed :P
Mitch VanDuyn
@catmando
May 30 2016 14:36
React.rb provides the client side view logic - no HTML or js needed. Any server side logic can be made with whatever framework you like, rails, Sinatra, etc.
By design it integrates nicely with rails is all
chewedon
@chewedon
May 30 2016 14:37
Do I need to learn React before I can use it?
Mitch VanDuyn
@catmando
May 30 2016 14:41
No
Do one of the tutorials and you will have the basics. One if beauties if react is its simplicity.
Play with the simple examples on the reactrb.org landing page
Then do the tutorial at http://reactrb.org/docs/tutorial.html
Should take just a couple of hours and you will have most of what u need to know
chewedon
@chewedon
May 30 2016 14:46
Okay.
chewedon
@chewedon
May 30 2016 15:01
Seems like this guy shoves everything into 1 file.
I can only assume there is a way to create folders and subfiles
To separate the logic from the HTML.
Mitch VanDuyn
@catmando
May 30 2016 15:12
Sure that is just to keep the tutorial simple
chewedon
@chewedon
May 30 2016 15:13
If React is just the view component...what about the routing etc ?
Making HTTP POST and GET request to a REST API, local database storage ?
Mitch VanDuyn
@catmando
May 30 2016 15:14
Let's discuss on
The zetachang/reactrb
Room
Search for react.rb in the gitter app
K
chewedon
@chewedon
May 30 2016 15:17
Missing the .rb
zetachang/react.rb
Doug Orleans
@dougo
May 30 2016 20:15
Hi all! Has anyone made a Rails engine that uses Opal? Currently I'm having trouble getting it to use OpalHelper#javascript_include_tag from opal-rails (0.8.1)
which is what it uses when it's an app.
Doug Orleans
@dougo
May 30 2016 21:01
hm, when I use rails console, helper.method(:javascript_include_tag) gets it from OpalHelper. But from inside my application layout, it's getting the one from Sprockets::Rails::Helper.
Jamie Gaskins
@jgaskins
May 30 2016 21:04
@dougo Is there a reason you want to get it to invoke the OpalHelper one specifically?
Doug Orleans
@dougo
May 30 2016 21:05
Yes, because that's the one that generates the code to actually call my application code. Otherwise it just defines a bunch of modules but never starts the app.
Jamie Gaskins
@jgaskins
May 30 2016 21:06
What version of Rails are you on?
Doug Orleans
@dougo
May 30 2016 21:06
specifically, it calls Opal::Processor.load_asset_code(sprockets, source)
rails 4.2.6
Jamie Gaskins
@jgaskins
May 30 2016 21:07
That's really weird. I use the stock javascript_include_tag in my application layout all the time and it loads right up.
Doug Orleans
@dougo
May 30 2016 21:07
yeah, I think it's something about how Rails engines are different from applications.
Jamie Gaskins
@jgaskins
May 30 2016 21:07
Oh, right, engines
Doug Orleans
@dougo
May 30 2016 21:08
I've been running into a few gotchas. Like, it doesn't auto-require all the gems it depends on, you have to require them all manually.
took me a while to track that down...
@jgaskins, I assume the "stock" javascript_include_tagin your app is actually coming from opal-rails. At least that's what I determined from my app (before I converted it to an engine)
Jamie Gaskins
@jgaskins
May 30 2016 21:18
Huh, weird. Opal registers itself with Sprockets as the handler for .rb and .opal files, so it shouldn't need to do that. It might be to paper over inconsistencies between Sprockets versions, though.
Doug Orleans
@dougo
May 30 2016 21:49
hm, seems to be a consequence of using isolate_namespace in the engine.
I get that that prevents helpers from the engine from polluting the app, but in this case it seems to be preventing a helper from the engine's dependencies from being visible in the engine.
adding helper OpalHelper into my engine's ApplicationController did the trick. whew!
Jamie Gaskins
@jgaskins
May 30 2016 22:09
@dougo Nice! :+1: