Yes that is exactly what I want.
OK , I copied my file in the models folder and I guess I need to
create the form in my view with a "form_tag", or? Or do I need the
"form_for"?
My problem is that I don't really know what I have to put in the
controller and my view (form) to call my model?
Can you give me a little example?
Sorry I am a real newbie to Rails. I am only good in Ruby.
What I have so far:
index.html.erb:
<% form_tag(???, :method=>'post') do %> #1. I don't know
what I have to put in here. The corresponding method in my
controller???
Request:<br />
<%= text_field_tag "request" %>
<%= submit_tag 'Submit' %>
<% end %>
<%=@results%> #3.
Should be output the results...
request.rb:
class Request
def initialize(myrequest)
.....--> send myrequest via net/http to the web service
end
end
home_controller.rb:
class HomeController < ApplicationController #2. I don't
know how to receive the value from the form and send it to my model
def index
end
end
On 11 Mrz., 15:34, Bryan Crossland <[email protected]> wrote:
> 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.