# Textbox input for an action: failed attempt

**URL:** <https://www.ruby-forum.com/t/textbox-input-for-an-action-failed-attempt/174412>\
**Category:** Rails\
**Created:** [August 26, 2009, 3:58pm UTC](https://www.ruby-forum.com/t/textbox-input-for-an-action-failed-attempt/174412 "2009-08-26T15:58:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![trevoke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@trevoke](https://www.ruby-forum.com/u/trevoke)\
**Post date:** [August 26, 2009, 3:58pm UTC](https://www.ruby-forum.com/t/textbox-input-for-an-action-failed-attempt/174412/1 "2009-08-26T15:58:33Z")

</div>

Okay, so this is what I have (which fails miserably) in my view:

Please enter a username:  
\<%= form\_remote\_tag :html =\> { :update =\> “filter\_counts”,  
:url =\> {:action =\> “search\_by\_name”} }do -%\>

\<%= text\_field\_tag 'username', :maxlength =\> 15, :size =\> 12 %\>

\<%= submit\_tag 'Search' %\>
 \<% end -%\>

“filter\_counts” is a div, “search\_by\_name” is the action, I think the  
rest makes sense.

And here is my error:

compile error  
C:/scripts/Rads/app/views/dictated\_exams/index.html.erb:5: syntax error,  
unexpected ‘)’  
:url =\> {:action =\> “search\_by\_name”} }do ).to\_s)  
^  
C:/scripts/Rads/app/views/dictated\_exams/index.html.erb:36: syntax  
error, unexpected kENSURE, expecting ‘)’  
C:/scripts/Rads/app/views/dictated\_exams/index.html.erb:38: syntax  
error, unexpected kEND, expecting ‘)’

Extracted source (around line #5):

2:   
3: Please enter part of a name (’%’ is the wild card character):  
4: \<%= form\_remote\_tag :html =\> { :update =\> “filter\_counts”,  
5: :url =\> {:action =\> “search\_by\_name”} }do -%\>  
6:

\<%= text\_field\_tag ‘username’, :maxlength =\> 15, :size =\> 12  
%\>
  
7: 
\<%= submit\_tag ‘Search’ %\>
  
8: \<% end -%\>
* * *

Help is much appreciated!

---

<div class="post-metadata">

**Author:** ![trevoke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@trevoke](https://www.ruby-forum.com/u/trevoke)\
**Post date:** [August 26, 2009, 4:43pm UTC](https://www.ruby-forum.com/t/textbox-input-for-an-action-failed-attempt/174412/2 "2009-08-26T16:43:20Z")

</div>

Fixed it.  
Note the teeny differences…

\<% form\_remote\_tag :update =\> “filter\_counts”,  
:url =\> {:action =\> “name\_filter”} do -%\>  
\<%= text\_field\_tag ‘search’, nil, :maxlength =\> 15, :size =\> 12 %\>  
\<%= submit\_tag ‘Search’ %\>  
\<% end -%\>

---

<div class="post-metadata">

**Author:** ![trevoke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@trevoke](https://www.ruby-forum.com/u/trevoke)\
**Post date:** [August 26, 2009, 5:57pm UTC](https://www.ruby-forum.com/t/textbox-input-for-an-action-failed-attempt/174412/3 "2009-08-26T17:57:57Z")

</div>

I don’t know how much this helps, but I’ve learned the hard way that,  
when I write

\<%= blah :blah, :blah do |x| %\>  
\<% end %\>

I get bizarre (and always incorrect) results.

The reason is that \<%= … %\> results in a string that gets inserted  
into your HTML stream, while \<% … %\> results in some Ruby code that  
gets executed with no output going to the HTML stream. If the Ruby  
code includes a block, then, presumably, that block will output the  
HTML stuff you were hoping to output.

–wpd

On Wed, Aug 26, 2009 at 9:58 AM, Aldric
