Textbox input for an action: failed attempt

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!

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 -%>

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