On Fri, Mar 11, 2011 at 3:23 AM, Sebastian
<[email protected]>wrote:
> Hi,
>
> I wrote pure Ruby code for consuming an existing web service. The
> requests are send via net/http and are in XML format. That means I
> have Ruby classes that look like this:
>
> class Request
> def initialize(myrequest)
> .....--> send myrequest via net/http to the web service
> end
> end
>
> To use that class I have the following code:
>
> f = Request.new("This is a request").xml
> p f
>
> Now I want to make a rails web form where I can type my request and
> send that to my existing classes to perform the request. All I found
> via search were forms that worked with databases. I don't need a
> database for that functionality. (I will need it later, when I store
> the results, but that comes later!)
>
> I already created a rails project and put my ruby file in the lib
> folder. In my controller I have the following:
>
>
> f = Request.new("This is a request").xml
> @out = p f
>
> So I am able to get the result of that request in my view via <%=@out
> %>, but that is static.
>
> How can I send "This is a request" via a web form from my view to that
> ruby file?
>
> I have no clue how to start. Again everything I find about rails is
> database stuff.
>
> I really hope that someone can help me here and give a clue how I can
> start.
>
>
If I understand you correctly, you are looking to submit a form to a rails
controller that will then access your Request model and return you the
results. It's pretty easy if that is what you are looking for. Take your
class Request code and save it in the model folder as is naming the file
request.rb. Then generate a controller that you want to call with the form
that will process the form and display requests. You can use all the
tutorial stuff you found already. You're just using a model that is not
connected to a database. The key here is that your model request.rb is not
inheriting from ActiveRecord::Base. It's just a stand alone class file that
you call like any other model.
B.
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.