# Error while deploying on Heroku : undefined method \`hooks'

**URL:** <https://community.forestadmin.com/t/error-while-deploying-on-heroku-undefined-method-hooks/4582>\
**Category:** Help me!\
**Created:** [April 28, 2022, 8:57am UTC](https://community.forestadmin.com/t/error-while-deploying-on-heroku-undefined-method-hooks/4582 "2022-04-28T08:57:10Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Florian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/florian/32/4336_2.png) [@Florian](https://community.forestadmin.com/u/Florian)\
**Post date:** [April 28, 2022, 8:57am UTC](https://community.forestadmin.com/t/error-while-deploying-on-heroku-undefined-method-hooks/4582/1 "2022-04-28T08:57:10Z")

</div>

Hi FA Community !

## Feature(s) impacted

> Deployment of FA on Heroku

## Observed behavior

> Job failed with Forest\_Liana 7.4.1  
> We aimed to restrict the search on specific fields ([https://docs.forestadmin.com/documentation/v/v7-v6-rails/how-tos/settings/restrict-the-search-on-specific-fields](https://docs.forestadmin.com/documentation/v/v7-v6-rails/how-tos/settings/restrict-the-search-on-specific-fields))  
> We tried an update on 7.5.1, but we keep having this error

## Failure Logs

```javascript
NoMethodError: undefined method `hooks' for nil:NilClass
/app/vendor/bundle/ruby/2.7.0/gems/forest_liana-7.5.1/lib/forest_liana/bootstrapper.rb:62:in `block (2 levels) in generate_action_hooks'
/app/vendor/bundle/ruby/2.7.0/gems/forest_liana-7.5.1/lib/forest_liana/bootstrapper.rb:58:in `each'
/app/vendor/bundle/ruby/2.7.0/gems/forest_liana-7.5.1/lib/forest_liana/bootstrapper.rb:58:in `block in generate_action_hooks'
/app/vendor/bundle/ruby/2.7.0/gems/forest_liana-7.5.1/lib/forest_liana/bootstrapper.rb:57:in `each'
/app/vendor/bundle/ruby/2.7.0/gems/forest_liana-7.5.1/lib/forest_liana/bootstrapper.rb:57:in `generate_action_hooks'
/app/vendor/bundle/ruby/2.7.0/gems/forest_liana-7.5.1/lib/forest_liana/bootstrapper.rb:86:in `generate_apimap'
/app/vendor/bundle/ruby/2.7.0/gems/forest_liana-7.5.1/lib/forest_liana/bootstrapper.rb:33:in `initialize'
/app/vendor/bundle/ruby/2.7.0/gems/forest_liana-7.5.1/lib/forest_liana/engine.rb:91:in `new'
/app/vendor/bundle/ruby/2.7.0/gems/forest_liana-7.5.1/lib/forest_liana/engine.rb:91:in `block in <class:Engine>'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.7/lib/active_support/lazy_load_hooks.rb:68:in `block in execute_hook'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.7/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.7/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.7/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.7/lib/active_support/lazy_load_hooks.rb:51:in `each'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.7/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.4.7/lib/rails/application/finisher.rb:129:in `block in <module:Finisher>'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.4.7/lib/rails/initializable.rb:32:in `instance_exec'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.4.7/lib/rails/initializable.rb:32:in `run'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.4.7/lib/rails/initializable.rb:61:in `block in run_initializers'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.4.7/lib/rails/initializable.rb:60:in `run_initializers'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.4.7/lib/rails/application.rb:363:in `initialize!'
/app/config/environment.rb:5:in `<main>'
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.7/lib/active_support/dependencies.rb:324:in `block in require'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.7/lib/active_support/dependencies.rb:291:in `load_dependency'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.4.7/lib/active_support/dependencies.rb:324:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.4.7/lib/rails/application.rb:339:in `require_environment!'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.4.7/lib/rails/application.rb:523:in `block in run_tasks_blocks'
/app/vendor/bundle/ruby/2.7.0/gems/sentry-ruby-core-4.9.2/lib/sentry/rake.rb:24:in `execute'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.4.7/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.4.7/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.4.7/lib/rails/command.rb:48:in `invoke'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.0.4.7/lib/rails/commands.rb:18:in `<main>'
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/app/bin/rails:9:in `<main>'
Tasks: TOP => db:migrate => db:load_config => environment

#

```

# Context

> - Project name: N/A
> - Team name: N/A
> - Environment name: N/A
> - Agent type & version: Forest liana Rails, v7.5.1, with Postgres database
> - Ruby 2.7.5

---

<div class="post-metadata">

**Author:** ![matthv](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/matthv/32/3269_2.png) [@matthv](https://community.forestadmin.com/u/matthv)\
**Post date:** [April 28, 2022, 9:57am UTC](https://community.forestadmin.com/t/error-while-deploying-on-heroku-undefined-method-hooks/4582/3 "2022-04-28T09:57:40Z")

</div>

Hey @Florian, and welcome to our community 👋

Could you share your project name and the forest collection that implements the search on specific fields.

Can your confirm that your issue appears only in production not in local environment.

---

<div class="post-metadata">

**Author:** ![Florian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/florian/32/4336_2.png) [@Florian](https://community.forestadmin.com/u/Florian)\
**Post date:** [April 28, 2022, 12:55pm UTC](https://community.forestadmin.com/t/error-while-deploying-on-heroku-undefined-method-hooks/4582/4 "2022-04-28T12:55:23Z")

</div>

Hello @matthv and thank you !  
The project name is Ilek BO and the collection is Subscription.  
And yes, it only appears in production, it works in local environnement

---

<div class="post-metadata">

**Author:** ![matthv](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/matthv/32/3269_2.png) [@matthv](https://community.forestadmin.com/u/matthv)\
**Post date:** [April 28, 2022, 1:35pm UTC](https://community.forestadmin.com/t/error-while-deploying-on-heroku-undefined-method-hooks/4582/5 "2022-04-28T13:35:07Z")

</div>

Could your share the code of the Subscription collection too.

I’ll try to test on my end.

---

<div class="post-metadata">

**Author:** ![Florian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/florian/32/4336_2.png) [@Florian](https://community.forestadmin.com/u/Florian)\
**Post date:** [April 28, 2022, 1:44pm UTC](https://community.forestadmin.com/t/error-while-deploying-on-heroku-undefined-method-hooks/4582/6 "2022-04-28T13:44:57Z")

</div>

ok i send you a private message with that. Thanks

---

<div class="post-metadata">

**Author:** ![matthv](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/matthv/32/3269_2.png) [@matthv](https://community.forestadmin.com/u/matthv)\
**Post date:** [April 28, 2022, 3:23pm UTC](https://community.forestadmin.com/t/error-while-deploying-on-heroku-undefined-method-hooks/4582/7 "2022-04-28T15:23:31Z")

</div>

It doesn’t seem to be related to your implementation of search\_fields.

The log seems to indicate that there is an error on the apimap.  
Could you check that you have commit your .forestadmin-schema.json file along with your code?

I think, there is still a smart action in your schema and it no longer exists in your current code.

---

<div class="post-metadata">

**Author:** ![Florian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/florian/32/4336_2.png) [@Florian](https://community.forestadmin.com/u/Florian)\
**Post date:** [April 28, 2022, 3:47pm UTC](https://community.forestadmin.com/t/error-while-deploying-on-heroku-undefined-method-hooks/4582/8 "2022-04-28T15:47:47Z")

</div>

Yes it was commit when updating from 7.4.1 to 7.5.1 (even if it did not work with the previous version)

Here the meta settings :

```javascript
  "meta": {
    "liana": "forest-rails",
    "liana_version": "7.5.1",
    "stack": {
      "database_type": "postgresql",
      "orm_version": "6.0.4.7"
}

```

But now you mention it, i see an action on a collection :

```javascript
 "actions": [{
      "name": "Change password",
      "type": "bulk",
      "base_url": null,
      "endpoint": "forest/actions/change-password",
      "http_method": "POST",
      "redirect": null,
      "download": false,
      "fields": [{
        "field": "New password",
        "type": "String",
        "default_value": null,
        "enums": null,
        "is_required": false,
        "is_read_only": false,
        "reference": null,
        "description": null,
        "position": 0,
        "widget": null
      }],
      "hooks": {
        "load": false,
        "change": []
      }
    }]

```

Is it related ?

---

<div class="post-metadata">

**Author:** ![matthv](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/matthv/32/3269_2.png) [@matthv](https://community.forestadmin.com/u/matthv)\
**Post date:** [April 29, 2022, 8:36am UTC](https://community.forestadmin.com/t/error-while-deploying-on-heroku-undefined-method-hooks/4582/9 "2022-04-29T08:36:02Z")

</div>

It might be related, this smart action is provided by our package if you use the devise gem.

However, have you recently used or removed the devise gem on your app?

---

<div class="post-metadata">

**Author:** ![Florian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/florian/32/4336_2.png) [@Florian](https://community.forestadmin.com/u/Florian)\
**Post date:** [April 29, 2022, 9:50am UTC](https://community.forestadmin.com/t/error-while-deploying-on-heroku-undefined-method-hooks/4582/10 "2022-04-29T09:50:07Z")

</div>

Yes we use it for the authentication, in the latest version 4.8.1

---

<div class="post-metadata">

**Author:** ![matthv](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/matthv/32/3269_2.png) [@matthv](https://community.forestadmin.com/u/matthv)\
**Post date:** [April 29, 2022, 10:32am UTC](https://community.forestadmin.com/t/error-while-deploying-on-heroku-undefined-method-hooks/4582/11 "2022-04-29T10:32:32Z")

</div>

Well, still not able to reproduce on my end.

I suggest you do the test to remove this smart action.  
Could you in your local environment comment out the line that defines `devise` on your `models/user.rb`

`#devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable`

Then run your rails server, that will generate a new .forestschema-admin.json without the smart action.  
After that commit and push this schema to your production.

(don’t forget to remove the comment on the devise line)

---

<div class="post-metadata">

**Author:** ![Florian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/florian/32/4336_2.png) [@Florian](https://community.forestadmin.com/u/Florian)\
**Post date:** [April 29, 2022, 12:27pm UTC](https://community.forestadmin.com/t/error-while-deploying-on-heroku-undefined-method-hooks/4582/12 "2022-04-29T12:27:33Z")

</div>

ok i am going to try that !

---

<div class="post-metadata">

**Author:** ![Florian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/florian/32/4336_2.png) [@Florian](https://community.forestadmin.com/u/Florian)\
**Post date:** [April 29, 2022, 3:28pm UTC](https://community.forestadmin.com/t/error-while-deploying-on-heroku-undefined-method-hooks/4582/13 "2022-04-29T15:28:13Z")

</div>

We just successfully pushed in Production !!!  
Thanks for the help 💪  
The problem now is that dev will re-add the action when generating the forestschema.  
We can’t manage this manually each time.  
Do you know if a fix for this issue is going to be deployed in a future release ?

---

<div class="post-metadata">

**Author:** ![matthv](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/matthv/32/3269_2.png) [@matthv](https://community.forestadmin.com/u/matthv)\
**Post date:** [May 11, 2022, 8:18am UTC](https://community.forestadmin.com/t/error-while-deploying-on-heroku-undefined-method-hooks/4582/14 "2022-05-11T08:18:05Z")

</div>

Hello @Florian, this issue has been fixed in the latest 7.6.2 release
