Hello

I made a quite simple ruby web app. It uses scrubyt and mysql to store
results as cached results. The program is quite simple. It shows a
form, you enter a value and the controller makes an external http
call, parse the data and show the result for the user.

But I have a problem. I have the requirement to let a ruby program
from command line more or less run the same function that on web is
been handled by the form controller.

How can I re-use the web app when doing a standalone program callable
from command line? I dont want to recode as all the app is already
functioning. I am requested to do a ruby program that is called like
this:

ruby ./client.rb some_param

Where should I put this client.rb? How do I use the code from the
application that runs on the web?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Fernando Almeida at Oct 1, 2012 at 12:56 pm
    http://guides.rubyonrails.org/command_line.html#rails-runner

    2012/9/30 Sta Canovist <stacanovist@gmail.com>
    Hello

    I made a quite simple ruby web app. It uses scrubyt and mysql to store
    results as cached results. The program is quite simple. It shows a
    form, you enter a value and the controller makes an external http
    call, parse the data and show the result for the user.

    But I have a problem. I have the requirement to let a ruby program
    from command line more or less run the same function that on web is
    been handled by the form controller.

    How can I re-use the web app when doing a standalone program callable
    from command line? I dont want to recode as all the app is already
    functioning. I am requested to do a ruby program that is called like
    this:

    ruby ./client.rb some_param

    Where should I put this client.rb? How do I use the code from the
    application that runs on the web?

    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to
    rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.


    --
    Fernando Almeida
    www.fernandoalmeida.net

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Walter Lee Davis at Oct 1, 2012 at 1:02 pm

    On Sep 30, 2012, at 2:12 AM, Sta Canovist wrote:

    Hello

    I made a quite simple ruby web app. It uses scrubyt and mysql to store
    results as cached results. The program is quite simple. It shows a
    form, you enter a value and the controller makes an external http
    call, parse the data and show the result for the user.

    But I have a problem. I have the requirement to let a ruby program
    from command line more or less run the same function that on web is
    been handled by the form controller.

    How can I re-use the web app when doing a standalone program callable
    from command line? I dont want to recode as all the app is already
    functioning. I am requested to do a ruby program that is called like
    this:

    ruby ./client.rb some_param

    Where should I put this client.rb? How do I use the code from the
    application that runs on the web?
    Have a google for 'command-line ruby' and read up on the gets() method. As far as where to put client.rb, that could be anywhere given the command-line you quoted. Starting the ruby method's first argument with a dot-slash means "starting in the current directory…" and the rest just points the ruby executable to the file client.rb in that directory. Are you meaning to call a Rails application using this command-line interface? Have a read on the Rails Runner. I don't remember anything about it except I saw it mentioned in passing in AWDWROR when I read it years ago, never used it.

    Walter

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedOct 1, '12 at 12:26p
activeOct 1, '12 at 1:02p
posts3
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase