i have a fresh rails application called basic… i have boot strap
working and looking to create a button that if pressed will launch a
ruby script and display its live output as it happens…
The web page and any javascript in it run in the browser. Which
computer do you want the ruby script to run on? The server running
your rails app or the client PC running in the browser?
If you answer is the PC running the browser then, for a start, how
would you even know that ruby is installed on that PC? It is for
exactly that sort of task that javascript was invented.
exactly that sort of task that javascript was invented.
i dont know what im doing, but im excited to learn…
Basically no, you can’t do that. There are ways you could make it
look as if that is what is happening, but that would not be the sort
of thing a beginner could knock off easily. I would get the hang of
the conventional web architecture before trying to push the
boundaries.
exactly that sort of task that javascript was invented.
i dont know what im doing, but im excited to learn…
Basically no, you can’t do that. There are ways you could make it
look as if that is what is happening, but that would not be the sort
of thing a beginner could knock off easily. I would get the hang of
the conventional web architecture before trying to push the
boundaries.
Colin
Maybe just a example for if button is pressed then <=%puts ‘hi WORLD’=>
The web page and any javascript in it run in the browser. Which
computer do you want the ruby script to run on? The server running
your rails app or the client PC running in the browser?
If you answer is the PC running the browser then, for a start, how
would you even know that ruby is installed on that PC? It is for
exactly that sort of task that javascript was invented.
Colin
no, i want to run ruby code on the server and display the console output
to the viewer in real time as each line is displayed
<%=# if button is pressed=>
button
<%=100.times do |x| puts x; sleep 1; end=>
i dont know what im doing, but im excited to learn…
exactly that sort of task that javascript was invented.
i dont know what im doing, but im excited to learn…
Basically no, you can’t do that. There are ways you could make it
look as if that is what is happening, but that would not be the sort
of thing a beginner could knock off easily. I would get the hang of
the conventional web architecture before trying to push the
boundaries.
Colin
Maybe just a example for if button is pressed then <=%puts ‘hi WORLD’=>
I found gem puma, seems like the right place to start
I have found the right module actioncontroler::live
That will not let you do what you said you wanted to do, which was put
the following on a web page
<%= 100.times do |i|%>
<%= print i*i%>
<%= sleep 1%>
<%=end%>
and have it update the screen in real time.
I said that was not possible and asked you to tell us what you were
actually trying to achieve. Had you answered that question we could
probably have saved you a lot of time by pointing you in the right
direction.
As for a button to trigger the event, ill have to make due with a
href=>/liveStream-hiWorld.ntml.erb
Please quote the message you are replying to, this is a mailing list
not a forum (though you may be accessing it via a forum like
interface) so it is not clear to what you are replying. Thanks.
You specifically requested that the script be embedded in the the web
page. Your example is just live streaming from the controller.
I don’t think that href will work very well. If you look for examples
of using the live feature you will find how to stream into your web
page.
As for a button to trigger the event, ill have to make due with a
href=>/liveStream-hiWorld.ntml.erb
Please quote the message you are replying to, this is a mailing list
not a forum (though you may be accessing it via a forum like
interface) so it is not clear to what you are replying. Thanks.
You specifically requested that the script be embedded in the the web
page. Your example is just live streaming from the controller.
I don’t think that href will work very well. If you look for examples
of using the live feature you will find how to stream into your web
page.
Colin
/messaging/index.html.erb
Im using the actioncontroller::live example found on the domentation
site, i have things setup properly with routes.rb…
I can successfully append data to a
in the clients browser.
But the browser will keep streaming in a endless loop. Maybe this is
expected behaviour?
As for a button to trigger the event, ill have to make due with a
href=>/liveStream-hiWorld.ntml.erb
Please quote the message you are replying to, this is a mailing list
not a forum (though you may be accessing it via a forum like
interface) so it is not clear to what you are replying. Thanks.
You specifically requested that the script be embedded in the the web
page. Your example is just live streaming from the controller.
I don’t think that href will work very well. If you look for examples
of using the live feature you will find how to stream into your web
page.
Colin
/messaging/index.html.erb
Im using the actioncontroller::live example found on the domentation
site, i have things setup properly with routes.rb…
I can successfully append data to a
in the clients browser.
But the browser will keep streaming in a endless loop. Maybe this is
expected behaviour?
ensure
response.stream.close
it seems that this part of the controller does nothing.
if i add to my index.html.erb source.close(); then it will effectively
close the stream. so with that said, i could do a if expressions on the
client side “if stream_kill, then source.close():”
interface) so it is not clear to what you are replying. Thanks.
/messaging/index.html.erb
But the browser will keep streaming in a endless loop. Maybe this is
expected behaviour?
ensure
response.stream.close
Can you copy/paste the code you are using to do the streaming in the
controller please.
Colin
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.