Trying to create a search on my homepage using simple_form (almost the same as formtastic). The search works fine, and I get my results, but after submitting, I want to save the values with what the user submitted.
I use a namespace for my form, so how to save data for the form. Here is some code that might help.
controller
def index
@results = Property.search(params[:search])
end
View
%h1 Search Form
= simple_form_for(:search) do |f|
= f.input :location, :as => :select, :collection => Location.all.asc(:name)
= f.input :type, :collection => PropertyType.all.asc(:name)
= f.input :bedrooms, :collection => 1..10,
%p.box
= f.button :submit
-if @results
%h1 Search Results
.results
- @results.each do |property|
.result
%h1= property.title
In the Index controller, I tried all kinds of things, i.e.
@search = params[:search]
But every time I try something, the search is interrupted.
What am I doing wrong?
I hope you can advise
source
share