現在railsでタスク管理アプリを作っていてransackを用いて検索機能を実装したいと考えております。  
しかし、該当のページを読み込む際に下記のようなエラーが出ます。

```

    ransack (2.3.0) lib/ransack/helpers/form_helper.rb:21:in `search_form_for'
    app/views/tasks/index.html.slim:5:in `_app_views_tasks_index_html_slim___1759395067466273319_70242397935860'
    actionview (5.2.3) lib/action_view/template.rb:159:in `block in render'
    activesupport (5.2.3) lib/active_support/notifications.rb:170:in `instrument'
    actionview (5.2.3) lib/action_view/template.rb:354:in `instrument_render_template'
    actionview (5.2.3) lib/action_view/template.rb:157:in `render'
    actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
    actionview (5.2.3) lib/action_view/renderer/abstract_renderer.rb:44:in `block in instrument'
    activesupport (5.2.3) lib/active_support/notifications.rb:168:in `block in instrument'
    activesupport (5.2.3) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    activesupport (5.2.3) lib/active_support/notifications.rb:168:in `instrument'
    actionview (5.2.3) lib/action_view/renderer/abstract_renderer.rb:43:in `instrument'
    actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
    actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
    actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
    actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:16:in `render'
    actionview (5.2.3) lib/action_view/renderer/renderer.rb:44:in `render_template'
    actionview (5.2.3) lib/action_view/renderer/renderer.rb:25:in `render'
    actionview (5.2.3) lib/action_view/rendering.rb:103:in `_render_template'
    actionpack (5.2.3) lib/action_controller/metal/streaming.rb:219:in `_render_template'
    actionview (5.2.3) lib/action_view/rendering.rb:84:in `render_to_body'
    actionpack (5.2.3) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
    actionpack (5.2.3) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
    actionpack (5.2.3) lib/abstract_controller/rendering.rb:25:in `render'
    actionpack (5.2.3) lib/action_controller/metal/rendering.rb:36:in `render'
    actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:46:in `block (2 levels) in render'
    activesupport (5.2.3) lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
    /Users/keisuke713/.rbenv/versions/2.6.3/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
    activesupport (5.2.3) lib/active_support/core_ext/benchmark.rb:14:in `ms'
    actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:46:in `block in render'
    actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
    activerecord (5.2.3) lib/active_record/railties/controller_runtime.rb:31:in `cleanup_view_runtime'
    actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:45:in `render'
    actionpack (5.2.3) lib/action_controller/metal/implicit_render.rb:35:in `default_render'
    actionpack (5.2.3) lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
    actionpack (5.2.3) lib/action_controller/metal/basic_implicit_render.rb:6:in `tap'
    actionpack (5.2.3) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
    actionpack (5.2.3) lib/abstract_controller/base.rb:194:in `process_action'
    actionpack (5.2.3) lib/action_controller/metal/rendering.rb:30:in `process_action'
    actionpack (5.2.3) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
    activesupport (5.2.3) lib/active_support/callbacks.rb:132:in `run_callbacks'
    actionpack (5.2.3) lib/abstract_controller/callbacks.rb:41:in `process_action'
    actionpack (5.2.3) lib/action_controller/metal/rescue.rb:22:in `process_action'
    actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
    activesupport (5.2.3) lib/active_support/notifications.rb:168:in `block in instrument'
    activesupport (5.2.3) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    activesupport (5.2.3) lib/active_support/notifications.rb:168:in `instrument'
    actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
    actionpack (5.2.3) lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
    activerecord (5.2.3) lib/active_record/railties/controller_runtime.rb:24:in `process_action'
    actionpack (5.2.3) lib/abstract_controller/base.rb:134:in `process'
    actionview (5.2.3) lib/action_view/rendering.rb:32:in `process'
    actionpack (5.2.3) lib/action_controller/metal.rb:191:in `dispatch'
    actionpack (5.2.3) lib/action_controller/metal.rb:252:in `dispatch'
    actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
    actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:34:in `serve'
    actionpack (5.2.3) lib/action_dispatch/journey/router.rb:52:in `block in serve'
    actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `each'
    actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `serve'
    actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:840:in `call'
    warden (1.2.8) lib/warden/manager.rb:36:in `block in call'
    warden (1.2.8) lib/warden/manager.rb:34:in `catch'
    warden (1.2.8) lib/warden/manager.rb:34:in `call'
    rack (2.0.7) lib/rack/tempfile_reaper.rb:15:in `call'
    rack (2.0.7) lib/rack/etag.rb:25:in `call'
    rack (2.0.7) lib/rack/conditional_get.rb:25:in `call'
    rack (2.0.7) lib/rack/head.rb:12:in `call'
    actionpack (5.2.3) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
    rack (2.0.7) lib/rack/session/abstract/id.rb:232:in `context'
    rack (2.0.7) lib/rack/session/abstract/id.rb:226:in `call'
    actionpack (5.2.3) lib/action_dispatch/middleware/cookies.rb:670:in `call'
    activerecord (5.2.3) lib/active_record/migration.rb:559:in `call'
    actionpack (5.2.3) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
    activesupport (5.2.3) lib/active_support/callbacks.rb:98:in `run_callbacks'
    actionpack (5.2.3) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
    actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
    actionpack (5.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
    web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
    web-console (3.7.0) lib/web_console/middleware.rb:30:in `block in call'
    web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
    web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
    actionpack (5.2.3) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
    railties (5.2.3) lib/rails/rack/logger.rb:38:in `call_app'
    railties (5.2.3) lib/rails/rack/logger.rb:26:in `block in call'
    activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `block in tagged'
    activesupport (5.2.3) lib/active_support/tagged_logging.rb:28:in `tagged'
    activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `tagged'
    railties (5.2.3) lib/rails/rack/logger.rb:26:in `call'
    sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
    actionpack (5.2.3) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
    actionpack (5.2.3) lib/action_dispatch/middleware/request_id.rb:27:in `call'
    rack (2.0.7) lib/rack/method_override.rb:22:in `call'
    rack (2.0.7) lib/rack/runtime.rb:22:in `call'
    activesupport (5.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
    actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
    actionpack (5.2.3) lib/action_dispatch/middleware/static.rb:127:in `call'
    rack (2.0.7) lib/rack/sendfile.rb:111:in `call'
    railties (5.2.3) lib/rails/engine.rb:524:in `call'
    puma (3.12.1) lib/puma/configuration.rb:227:in `call'
    puma (3.12.1) lib/puma/server.rb:660:in `handle_request'
    puma (3.12.1) lib/puma/server.rb:474:in `process_client'
    puma (3.12.1) lib/puma/server.rb:334:in `block in run'
    puma (3.12.1) lib/puma/thread_pool.rb:135:in `block in spawn_thread'
    
```

controllerとviewは以下の通りです。

tasks_controller.rb

```

    def index
      @q = current_user.tasks.ransack(params[:q]
      @tasks = @q.result(distinct: true)
    end
    
```

index.html.slim

```

    h1 All tasks
    = search_form_for @q do |f|
      = f.label :title_cont, 'タイトル'
      = f.search_field :title_cont
      = f.submit 
    
```

**試したこと**  
一度viewの検索フォームを消してリロードしたところ通常通りにページが表示されたのでcontrollerの定義に間違いはないと思います。

以上、もしわかるかたいたらご教示ください。よろしくお願いします。
CC BY-SA 4.0
2019-11-25T22:45:27.693
60841
2019-11-27T00:36:20.660
2019-11-27T00:36:20.660
3060
35372
question
ruby-on-rails ruby
railsでransackを用いて検索機能を実装しようとしてもエラーになる