We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 891fbbc commit defc9b1Copy full SHA for defc9b1
app/controllers/searches_controller.rb
@@ -6,7 +6,11 @@ def new
6
end
7
8
def results
9
- @search = Search.new(search_params)
+ begin
10
+ @search = Search.new(search_params)
11
+ rescue ActionController::ParameterMissing
12
+ redirect_to search_path and return
13
+ end
14
15
if @search.valid?
16
respond_to do |format|
spec/requests/search_spec.rb
@@ -20,4 +20,9 @@
20
expect(response).to be_successful
21
expect(response.body).to include("There is a problem")
22
23
+
24
+ it "redirects when there are no search params" do
25
+ get search_results_path
26
+ expect(response).to redirect_to search_path
27
28
0 commit comments