On Fri, Mar 11, 2011 at 9:01 AM, Sebastian
<[email protected]>wrote:

> 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
>
>
You are definitely on the right track. Knowing Ruby before you learn Rails
will give you a huge leg up when creating applications on Rails. Picking up
the framework is easy and you'll get the hang of it soon enough.

For what you are trying to do you should not use index as that is mostly
just for showing what you already know. You can change that behavior in the
routing file but that is a more advanced topic for another day. To get you
to where you want to be, the simplest example for handling a form is in
section 6.7 (and up) from this tutorial:
http://edgeguides.rubyonrails.org/getting_started.html#listing-all-posts .
When looking at it, think of the Post model as your own Request model. They
are the same except you are not using a database. So where you see Post.all
or Post.find just know that if you want to use those methods you would have
to write them yourself in your model or hook your model to a db through
ActiveRecord.

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.

Reply via email to