Forum: Ruby on Rails Accessing values of the form

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Antonio F. (Guest)
on 2007-07-30 18:02
Hello.
Im new on rails, and i'm trying to make a page that will invoque a
webservice.
But since im new on rails, i'm trying to make a simple thing, trying to
pass the values of a form to a new page.

I've got this form:

<%= start_form_tag :action => "mostra", :id => @parametro %>
<table>
<tr><td>Tipo entidade</td>
<td> <%= select( "pesquisa", "value", { "Empresa" => "0", "Individual"
=> "1", "Desconhecido"=>"2"}) %></td></tr>
<tr><td>Lingua</td>
<td> <%= select :pesquisa, :language, @SiteLanguages,
{:selected=>@selected_language} %></td></tr>
<tr><td>Nome</td>
<td><%= text_field :pesquisa, :nome, :maxLength => 70, :size => 70
%></td></tr>
<tr><td>NIF</td>
<td><%= text_field :pesquisa, :nif, :maxLength=>9, :size=>9
%></td></tr>
<tr><td>Telefone</td>
<td><%= text_field :pesquisa, :telefone, :maxLength => 15, :size= =>15
%></td></tr>
<tr><td>Num. Coface</td>
<td><%= text_field :pesquisa, :numCoface, :maxLength=>8, :size=>8
%></td></tr>
<tr><td>Distrito</td>
<td> <%= select :pesquisa, :distrito, @Distritos, {:selected=>
@selected_distrito} %></td></tr>
<tr><td>Concelho</td>
<td><%= text_field :pesquisa, :concelho  %></td></tr>
<tr><td>Codigo postal</td>
<td><%= text_field :pesquisa, :codPostal, :maxLength=>8, :size=>8
%></td></tr>
</table>
<%= submit_tag 'Pesquisar' %>
<%= end_form_tag %>

ANd this is my controler:
class ClfController < ApplicationController
  def pesquisa
    @time = Time.now

    @SiteLanguages = ['en', 'de', 'fr']
    @selected_language = 'en'

    @TipoEntidade = ['Empresa', 'Individual', 'Desconhecido']
    @selected_tipoEntidade = 'Empresa'


    @Distritos = ['Aveiro','Beja', 'Braga', 'Braganca', 'Castelo
Branco', 'Coimbra', 'Évora', 'Faro', 'Guarda', 'Leiria', 'Lisboa',
'Portalegre' , 'Porto' ,'Santarem' ,'Setubal', 'Viana do Castelo', 'Vila
Real' , 'Viseu', 'Angra do Heroismo', 'Horta', 'Ponta Delgada',
'Funchal']
    @selected_distrito = 'Braganca'
  end

  def mostra

     if request.post?
      @time = Time.now
      @parametro = 12
      #redirect_to :action => 'pesquisa'
     end

    #@items = Clf.find(pesquisa[nome])
  end

Can anybody give me a help teling me how do i access in the controller
to the values submited from the form.

Thank you in advance,
Capi
Jeff E. (Guest)
on 2007-07-31 06:56
(Received via mailing list)
in the params hash

e.g.
  text_field :foo, :bar == params[:foo][:bar]


On Jul 30, 10:02 am, Antonio Fernandes <rails-mailing-l...@andreas-
This topic is locked and can not be replied to.