I have a simple form that I want to use to search surnames:
<form method="POST" action="<%= url_for :action => :index %>">
<label for="surname" class="itemLabel">Search Surname</label>
<input type="text" id="surname" name="surname" class="" <%= placeholder("Surname") %> />
<input type="submit" value="Search"/>
</form>
In the controller index method I have the following code:
def index
if @params['surname'].nil? or @params['surname'].empty?
@fencers = Fencer.find(:all)
else
@fencers = Fencer.find(:all, :conditions => {:surname => @params['surname']})
end
render :back => '/app'
end
If it has a surname param then it searches, if not it will just display all available. When I debug this action I never see any params when it gets called after posting the search form.
This search form is based on the auto-generated login form (which works) so I'm a bit confused. Any ideas?
Try posting to different action within your controller, or rename your index action to something like [model]_index.
Rhodes seems to like to mess around with query parameters passed to the index action.
I ran a quick test using your code and if you change the controller method to "index_new", the arguments are passed successfully.