SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist ikeo's Avatar
    Join Date
    Oct 2004
    Location
    Austin Texas
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I get the output from a controller action into a string

    so say I have a controller such that

    /quote/xml/200
    produces an xml document

    and I want to create an action "post" in the "quote" controller so that

    /quote/post/200
    takes the xml document produced from action "xml" (eg: "/quote/xml/200"), stores it in a string and posts that to a certain url.

    how could I go about doing that?


    Right now I'm just using the net/http class and trying to do this

    PHP Code:
    url URI.parse("http://localhost:3000/quote/xml/200")
    response Net::HTTP.get_response(url
    but even that is just hanging on the second line of that code
    eventually throwing an

    execution expired
    error.

    any ideas?
    Last edited by ikeo; Apr 17, 2008 at 00:53.

  2. #2
    SitePoint Evangelist ikeo's Avatar
    Join Date
    Oct 2004
    Location
    Austin Texas
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys ... figured it out

    This stores it in a string as I want

    Code:
    @xml = render_component_as_string :controller => "quote", :action => "xml", :params => {:request_id => params[:id] }
    and from there you can use the net/http or open-uri libraries to do the posting.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •