Thank you very much you both:
My form is now working and looking like this:
<form method="get" >
Value1: <%= text_field_tag 'Value1', params[:value1] %>
Value2: <%= text_field_tag 'Value2', params[:value2] %>
Value3: <%= text_field_tag 'Value3', params[:value3] %>
<%= submit_tag "Submit" %>
</form>
I followed the advice from Micheal and used pure html form. Rails form
is also working if I use this:
<% form_tag nil, :method => :get do %>
Value1: <%= text_field_tag 'Value1', params[:value1] %>
Value2: <%= text_field_tag 'Value2', params[:value2] %>
Value3: <%= text_field_tag 'Value3', params[:value3] %>
<% end %>
Is there any disadvantage to use pure html or rails???
My controller is looking this:
def index
@var1 = Mywebservice.new(params[:value1], params[:value1],
params[:value1]) if params[:value1]
end
So finally my controller is using the Mywebservice Model and save it
to the @var1, which can be read in my view.
I don't know if my code is beautiful, but it is working!!
Sebastian
On 11 Mrz., 16:32, Michael Pavling <[email protected]> wrote:
> On 11 March 2011 15:01, 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?
>
> You don't *need* anything in your form.. it could just be a plain ol'
> HTML form submitting to the URI of your controller.
> In the controller, the params hash will have all the values from the
> submitted form - so if you have a text input field named
> "request_to_run", you'll have a params value:
> params[:request_to_run]
>
> ...so you can do:
>
> my_request = Request.new(params[:request_to_run])
>
> (use debugging to confirm all the params values, etc, as I'm writing
> this off the top of my head! :-)
>
> In the controller action, populate "@results" with the results of your
> model (BTW, I wouldn't call it "Request"... that's a reserved word in
> Rails.
>
> @results = my_request.groovy_method_that_does_some_work
>
> in your view you can conditionally draw it:
>
> <%=h @results.inspect if @results %>
>
> On the whole though, if this is all you want your Rails app to do,
> then Rails is a bit of overkill. You'd (with your pure Ruby
> experience) probably find Sinatra makes more sense for such a
> requirement. Either way, Rails will do it too - it just loads up loads
> of other functionality you're never going to use :-)
--
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.