Still struggling with data flow

Hello,

The following view:

<%= start_form_tag %>
  Enter term to find
  <p>
    <%= text_field_tag :name, params[:name] %>
  </p>
    <%= link_to "Find",  { :action => 'find_term'} %>
<%= end_form_tag %>

does not appear to pass back the value of :name to the action:

def find_term
term = Term.find_by_name(params[:name])
if term
redirect_to :controller => “term”, :action => “show”, :id =>
term.id
else
flash[:notice] = “Unable to find the term: #{term}”
end
end

The notice printed is:

 Unable to find the term:

How do I pass back the value of the inputted variable to the controller?
'elp!

gk

The problem you have is you are putting a link in to form, expecting
that to
post the form. Try this…

replace your start_form_tag with <%= start_form_tag :action =>
‘find_term’
%>
and then repalce your link_to call with <%= submit_tag ‘Find’ %>

mark

Mark Van H. wrote:

The problem you have is you are putting a link in to form, expecting
that to
post the form. Try this…

replace your start_form_tag with <%= start_form_tag :action =>
‘find_term’
%>
and then repalce your link_to call with <%= submit_tag ‘Find’ %>

mark

Mark,
It works!
Thanks,
gk

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs