echo printer
2011-Nov-12 17:38 UTC
Can I drop-in a Ruby script and execute it within one of my Rails pages?
Is it possible to drop a Ruby script (around 50 lines) into one of your Rails pages? I am experimenting with doing this but I haven''t had any luck in finding out how. An example of what I am trying to do is to place a script like this https://github.com/johnyerhot/rquote/blob/master/lib/rquote.rb and see if I can''t drop it into a page like this simple view I made in Rails and have it print out the(stock) info on the page. I''ve already gotten it to print out a "Hello World" so I know everything is set up and running properly, just need to find out how to execute and print it to the page. Here is the code for the script, the controller and view is this helps: http://www.pastie.org/2852972 Thanks in advance, Jim -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/xcDjO297PqEJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-Nov-13 21:52 UTC
Re: Can I drop-in a Ruby script and execute it within one of my Rails pages?
On 12 November 2011 17:38, echo printer <jimmy.casey.3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Is it possible to drop a Ruby script (around 50 lines) into one of your > Rails pages? I am experimenting with doing this but I haven''t had any luck > in finding out how. > An example of what I am trying to do is to place a script like > this https://github.com/johnyerhot/rquote/blob/master/lib/rquote.rb and see > if I can''t drop it into a page like this simple view I made in Rails and > have it print out the(stock) info on the page.Do you mean you want it to run in the browser? If so then the answer is no. Ruby runs in the web server, use javascript if you want to run code in the browser. Colin> I''ve already gotten it to > print out a "Hello World" so I know everything is set up and running > properly, just need to find out how to execute and print it to the page. > Here is the code for the script, the controller and view is this > helps: http://www.pastie.org/2852972 > Thanks in advance, > Jim-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Norm Scherer
2011-Nov-14 05:39 UTC
Re: Can I drop-in a Ruby script and execute it within one of my Rails pages?
On 11/12/2011 10:38 AM, echo printer wrote:> Is it possible to drop a Ruby script (around 50 lines) into one of > your Rails pages? I am experimenting with doing this but I haven''t had > any luck in finding out how. >As Colin Law said you cannot execute it in the browser but there are probably other things you can do. You could put it in a helper file and invoke it from the view or you could embed it in the view (xx.html.erb) between <%= and %> and it would be interpreted and its output would go out to the browser.> An example of what I am trying to do is to place a script like this > https://github.com/johnyerhot/rquote/blob/master/lib/rquote.rb and see > if I can''t drop it into a page like this simple view I made in > Rails and have it print out the(stock) info on the page. I''ve already > gotten it to print out a "Hello World" so I know everything is set up > and running properly, just need to find out how to execute and print > it to the page. > > Here is the code for the script, the controller and view is this > helps: http://www.pastie.org/2852972 > > Thanks in advance, > Jim > -- > You received this message because you are subscribed to the Google > Groups "Ruby on Rails: Talk" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/xcDjO297PqEJ. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.