How do I embed ruby.rb file via form in a way that ruby.rb would be executed and results visible in view



let's say I want to embed this code via form in a separate ruby.rb file:


print "Hello, Please enter a value:"
var = gets.to_i
if var == 10
puts "Correct"
else
puts "Your answer is incorrect"
end

After the submit button in view user will see either results are correct or incorrect.
In a best way file ruby.rb would be embedded via form, it's more convinient, but not essential.
Could you think of how to make it work? I would be very nice to have some incentives from you.


Thank you


View Replies

Related to : How do I embed ruby.rb file via form in a way that ruby.rb would be executed and results visible in view


How do I embed ruby.rb file via form in a way that ruby.rb would be executed and results visible in view
Category : Programming Languages

let's say I want to embed this code via form in a separate ruby.rb file:


print "Hello, Please enter a value:"
var = gets.to_i
if var == 10
puts "Correct"
else
puts "Your answer is incorrect"
end

After the submit b


View Replies


Is there any way to increment a number each time the file gets executed in ruby
Category : Programming Languages

Is there any way to increment a no. each time the file gets executed in ruby.
I didn't find anything in this matter.
I want to declare a no. and then it will be incremented each time the file in which it resides gets executed.
I can use file to keep track of last no. used but is th


View Replies


ruby script executed from php not working, but ruby script works fine alone
Category : PHP

so i have ruby script that simply writes to a test.txt file with "hello"


i have a php script that executes this ruby script, when a user clicks a link.



i find that test.txt is empty.


however when i run by itself


$> ruby sayhi.rb



View Replies


IronRuby, How make ruby file executed from the regular C# project directory rather than bindebug folder?
Category : C & C++ & C#

Finding a proper title for my question wasn't easy, please feel free to re-edit if needed. Now:


In the following code the program crashes as soon as it runs.


using System;
using IronRuby;
using IronRuby.Runtime;
namespace IronRuby_Test_03
{

View Replies


How to embed Ruby in JavaScript (Rails + .html.erb file)
Category : Javascript

I have a .html.erb file, with some javascript in it. I would like to do something like this:


var stuff = '<div><%= @ruby_var.title %></div>'

What is the best way to do this? I may be totally off... Thanks.


View Replies


ruby eval method is halting the displaying of UI form in ruby on rails
Category : Web Design

I have written one helper method in rails that is populating the data in the select tag.


Data population in the select tag is done using eval method which evaluating some ruby code and after executing whatever data is returned from that ruby code it is then populated in the select_tag


View Replies


Get data from html form to ruby in Ruby on Rails
Category : Web Design

Get data from html form to ruby in Ruby on Rails


I have some html like this


<html>
<h1>Text to PDF</h1>
<textarea name="comments" cols="40" rows="5">
Enter your Text here...
</textarea><br>
<input type="sub

View Replies


hubris fails to install with: Missing C libraries: ruby, ruby, ruby
Category : Programming Languages

I am desperately trying to install Hubris but the installation fails whenever I run "cabal install".


Link to Hurbis:
https://github.com/mwotton/Hubris/tree/master/Haskell


Link to the Cabal file:
https://github.com/mwotton/Hubris/blob/master/Haskell/hubris.cabal


View Replies


Executing a ruby file without calling “ruby” on the terminal
Category : Network & Servers

I have an app on a file named todo with this shebang in the first line: #!/usr/bin/env ruby. On the terminal, I want to be able to run this file calling todo new "Some Task" and not ruby todo new "Some task", but I can't make it work; I always g


View Replies


Ruby on Rails: Can you put Ruby code in a YAML config file?
Category : Programming Languages

Sorry if this is a dumb question, but I am new to Ruby on Rails. I would like to do something like this in my amazon_s3.yml config file:


access_key_id: ENV['S3_KEY']
secret_access_key: ENV['S3_SECRET']

...but I know this isn't working. Not sure if it is ev


View Replies


2012 / 2017 Copyrights BigHow , All Rights Reserved .