View passing empty or no value to controller -- help

Hi,
I have the following view:

<%= start_form_tag ( { :action => 'find' }, :method => 'get') %>
  <p>
    <%= text_field_tag :lemma, params[:lemma] %>
  </p>
  <%= link_to "Find It", :class => "submit" %>
<%= end_form_tag %>

And the following find action in the controller:

def find
lemma = Lemma.find_by_lemma(params[:lemma])
if lemma
redirect_to (:controller => “lemma”, :action => “show”)
else
flash.now[:notice] = “Unable to find lemma: #{lemma}.”
end
end

It appears that the view does not pass back any value to the controller,
or passes an empty value, because the flash notice does not print any
value of the lemma, thus:

Unable to find lemma: .

What am I missing? Thanks for the help,
gk

Gene K. wrote:

or passes an empty value, because the flash notice does not print any
value of the lemma, thus:

Unable to find lemma: .

You want:

flash.now[:notice] = “Unable to find lemma: #{params[:lemma]}.”


We develop, watch us RoR, in numbers too big to ignore.

Mark Reginald J. wrote:

Gene K. wrote:

or passes an empty value, because the flash notice does not print any
value of the lemma, thus:

Unable to find lemma: .

You want:

flash.now[:notice] = “Unable to find lemma: #{params[:lemma]}.”


We develop, watch us RoR, in numbers too big to ignore.

Hi,
Thank you, yes, that makes sense. However it all the more confirmed that
the controller action is not getting any value back from the Find view
since the notice does not print any return value.
Thanks for taking the time to reply.
gk

Try

def find
p params

and look at the server output - do any parameters show up?

Also have a look at the html source generated by text_field.

Max

2006/8/6, Gene K. [email protected]:

Hi,
I have the following view:

<%= start_form_tag ( { :action => ‘find’ }, :method => ‘get’) %>


<%= text_field_tag :lemma, params[:lemma] %>


<%= link_to “Find It”, :class => “submit” %>
<%= end_form_tag %>

i’d guess the “find it” link does NOT submit the form. try sth like <%=
submit_tag(‘Find It’) %> instead. should work


Michael S. [email protected]

www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium

Max M. wrote:

Try

def find
p params

and look at the server output - do any parameters show up?

Also have a look at the html source generated by text_field.

Max

Down below are some relevant lines from development.log. The where
clause for the find sql is:

(eng_lemmas.“lemma” IS NULL )

Also, the url does not show the value to find (or that it is null):

[http://localhost/eng_lemma/find?class=submit]

I also added p params[:lemma] to the Find action, but the server.log is
empty. Is that where it will send the output to?

The helper text_field is expanded as:

The values of name and type are correct.

So it does look like the view is returning nothing or something that the
controller interprets as null. (pulling my hair)

Thanks,
gk

Processing EngLemmaController#find (for 127.0.0.1 at 2006-08-07
01:51:17) [GET]
Session ID: ea3ac9c50cc7a0d7bf5830462e8292ab
Parameters: {“class”=>“submit”, “action”=>“find”,
“controller”=>“eng_lemma”}
e[4;36;1mSQL (0.015000)e[0m e[0;1m SELECT a.attname,
format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = ‘eng_lemmas’::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
e[0m
e[4;35;1mEngLemma Load (0.141000)e[0m e[0mSELECT * FROM eng_lemmas
WHERE (eng_lemmas.“lemma” IS NULL ) LIMIT 1e[0m
Rendering within layouts/application
Rendering eng_lemma/find
Completed in 0.17200 (5 reqs/sec) | Rendering: 0.01600 (9%) | DB:
0.15600 (90%) | 200 OK [http://localhost/eng_lemma/find?class=submit]

Michael S. wrote:

2006/8/6, Gene K. [email protected]:

Hi,
I have the following view:

<%= start_form_tag ( { :action => ‘find’ }, :method => ‘get’) %>


<%= text_field_tag :lemma, params[:lemma] %>


<%= link_to “Find It”, :class => “submit” %>
<%= end_form_tag %>

i’d guess the “find it” link does NOT submit the form. try sth like <%=
submit_tag(‘Find It’) %> instead. should work


Michael S. [email protected]

www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium

That works! Strange, because in some of my other views,

link_to … :class = “submit”

works. It’s been a struggle; I need a drink here.

Thanks for the help.
gk