Im having an error that says:
Request-URI Too Large
Actually I’m trying to add a search function on my experimental rails 3 app which accepts a string and a date as search parameters. For some reasons when I click the submit button to do the search the URL in my browser is very long and Im having this error I mentioned above.
Here is the code for my model trap.rb:
class Trap < ActiveRecord::Base
def self.search(empcode, date_entry)
if empcode and date_entry
where('empcode LIKE ? and date_entry = ?', "%#{empcode}%", "#{date_entry}")
else
scoped
end
end
end
In the controller traps_controller.rb:
class TrapsController < ApplicationController
def index
@traps = Trap.search(params[:search_empcode], params[:search_date_entry])
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @traps }
end
end
.
.
.
end
And in the view index.html.erb:
<h2>TRAP 1.0</h2>
<%= form_tag traps_path, :method => 'get' do %>
<p>
Employee Code: <%= text_field_tag :search_empcode, params[:search_empcode] %>
Date Entry: <%= date_select :search_date_entry, params[:search_date_entry] %>
</p>
<p class="buttons"> <%= submit_tag "Search", :name => nil %></p>
<% end %>
<table>
<tr>
<th>Empcode</th>
<th>Date entry</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @traps.each do |trap| %>
<tr>
<td><%= trap.empcode %></td>
<td><%= trap.date_entry %></td>
<td><%= link_to 'Show', trap %></td>
<td><%= link_to 'Edit', edit_trap_path(trap) %></td>
<td><%= link_to 'Destroy', trap, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New Trap', new_trap_path %>
Can somebody tell me what’s wrong with this one? If you know some alternatives. Pls help…
I had this error authenticating against google’s openID actually, they redirected me back to my own app with a few hundred GET params. I didn’t figure out what the issue was, but instead of using the built in Rails server, I started using thin instead and the error magically disappeared. Must just be the way the server handles them internally.
Try
gem install thinthenthin startfrom your rails root directory.