# View passing empty or no value to controller -- help

**URL:** <https://www.ruby-forum.com/t/view-passing-empty-or-no-value-to-controller-help/101560>\
**Category:** Rails\
**Created:** [August 6, 2006, 6:29am UTC](https://www.ruby-forum.com/t/view-passing-empty-or-no-value-to-controller-help/101560 "2006-08-06T06:29:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kublai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a3d4f5/32.png) [@kublai](https://www.ruby-forum.com/u/kublai)\
**Post date:** [August 6, 2006, 6:29am UTC](https://www.ruby-forum.com/t/view-passing-empty-or-no-value-to-controller-help/101560/1 "2006-08-06T06:29:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kublai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a3d4f5/32.png) [@kublai](https://www.ruby-forum.com/u/kublai)\
**Post date:** [August 7, 2006, 6:29am UTC](https://www.ruby-forum.com/t/view-passing-empty-or-no-value-to-controller-help/101560/2 "2006-08-07T06:29:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kublai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a3d4f5/32.png) [@kublai](https://www.ruby-forum.com/u/kublai)\
**Post date:** [August 7, 2006, 8:01am UTC](https://www.ruby-forum.com/t/view-passing-empty-or-no-value-to-controller-help/101560/3 "2006-08-07T08:01:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kublai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a3d4f5/32.png) [@kublai](https://www.ruby-forum.com/u/kublai)\
**Post date:** [August 7, 2006, 8:39am UTC](https://www.ruby-forum.com/t/view-passing-empty-or-no-value-to-controller-help/101560/4 "2006-08-07T08:39:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kublai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a3d4f5/32.png) [@kublai](https://www.ruby-forum.com/u/kublai)\
**Post date:** [August 7, 2006, 10:33am UTC](https://www.ruby-forum.com/t/view-passing-empty-or-no-value-to-controller-help/101560/5 "2006-08-07T10:33:09Z")

</div>

2006/8/6, Gene K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

[www.stellar-legends.de](http://www.stellar-legends.de) - Weltraum-Browsergame im Alpha-Stadium

---

<div class="post-metadata">

**Author:** ![kublai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a3d4f5/32.png) [@kublai](https://www.ruby-forum.com/u/kublai)\
**Post date:** [August 7, 2006, 10:18am UTC](https://www.ruby-forum.com/t/view-passing-empty-or-no-value-to-controller-help/101560/6 "2006-08-07T10:18:30Z")

</div>

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](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](http://localhost/eng_lemma/find?class=submit)]

---

<div class="post-metadata">

**Author:** ![kublai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a3d4f5/32.png) [@kublai](https://www.ruby-forum.com/u/kublai)\
**Post date:** [August 7, 2006, 10:53am UTC](https://www.ruby-forum.com/t/view-passing-empty-or-no-value-to-controller-help/101560/7 "2006-08-07T10:53:22Z")

</div>

Michael S. wrote:

> 2006/8/6, Gene K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > 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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> 
> [www.stellar-legends.de](http://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
