# Strange change in form\_tag behavior from 2.0 to 2.1?

**URL:** <https://www.ruby-forum.com/t/strange-change-in-form-tag-behavior-from-2-0-to-2-1/144035>\
**Category:** Rails\
**Created:** [July 24, 2008, 8:26pm UTC](https://www.ruby-forum.com/t/strange-change-in-form-tag-behavior-from-2-0-to-2-1/144035 "2008-07-24T20:26:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 24, 2008, 8:26pm UTC](https://www.ruby-forum.com/t/strange-change-in-form-tag-behavior-from-2-0-to-2-1/144035/1 "2008-07-24T20:26:33Z")

</div>

I’ve used an approach frequently in the past where I create a method  
in the model that when passed parameters from a selection form returns  
a modified result set.  
As an example the routine in the model looks like this;

def self.find\_by\_search(params) (shortened for easy reading)  
where = []  
unless params[:agency].blank?  
where \<\< “agency\_id = :agency”  
end  
if where.empty?  
find(:all,  
:order =\> params[:order])  
else  
find(:all,  
:conditions =\> [where.join(" AND "), params],  
:order =\> params[:order])  
end  
end

Then the controller uses this model/method to modify the result set  
based on the user’s entries.

def ecase\_search  
@title = “Search Cases”  
return if params[:commit].nil?  
@ecase = @account.ecases.find\_by\_search(params)  
@ecases = @ecase.paginate :per\_page =\> 8,  
:page =\> params[:page]  
render(:template =\> “evidence/ecases/index”)  
end

The search form that is supposed to pass the params back to the  
controller action looks like this;

\<% form\_tag( ecase\_search\_path, :method =\> “get”) do %\> (shortened  
for easier reading)

 \> \<% @agencies = @account.agencies.find(:all) %\> \<% @agencies \< '', :description =\> 'All') %\> \<% @selections = %w(agency\_id incident\_id officer evidences\_count) %\> 

| \<%= "Search Field" %\> | \<%= "Search Value" %\> |
| --- | --- |
| **\<%= "Agency Code" %\>** | \<%= select\_tag(:agency, options\_for\_select(@agencies.collect { |c| [c.description, c.id] }), :style =\> "width:150px", :id =\> :indexselect) %\> |
| **\<%= "Order By" %\>** | \<%= select\_tag(:order, options\_for\_select(@selections), :style =\> "width:150px", :id =\> :indexselect) %\> |
| \<%= submit\_tag "Find Results", :class =\> "submit" %\> | |

\<% end %\>

The routing in routes.rb looks like this;

map.ecase\_search ‘ecase\_search’, :controller =\> ‘evidence/  
ecases’, :action =\> ‘ecase\_search’

The error I get when I try this approach is;

ActionController::MethodNotAllowed  
Only get, head, post, put, and delete requests are allowed.

This approach worked wonderfully in 2.0 but now fails in 2.1. I had a  
similar problem in 2.1 when I found that nested tables had to be  
called differently in the form\_for such as (\<% form\_for([@account,  
@agency]) do |form| % )  
Any thoughts are greatly appreciated.  
Kathleen

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 24, 2008, 11:28pm UTC](https://www.ruby-forum.com/t/strange-change-in-form-tag-behavior-from-2-0-to-2-1/144035/2 "2008-07-24T23:28:18Z")

</div>

You know what it was???  
The route somehow was not high enough up in the routes.rb file? I have  
no idea why this is as there’s not another route like this…but I just  
thought I might make someone’s day a little easier.  
Kathleen

On Jul 24, 12:25 pm, “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
