Error while deploying on Heroku : undefined method `hooks'

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 (Restrict the search on specific fields - Developer guide)
We tried an update on 7.5.1, but we keep having this error

Failure Logs

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- `block in execute_hook'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport- `with_execution_control'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport- `execute_hook'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport- `block in run_load_hooks'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport- `each'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport- `run_load_hooks'
/app/vendor/bundle/ruby/2.7.0/gems/railties- `block in <module:Finisher>'
/app/vendor/bundle/ruby/2.7.0/gems/railties- `instance_exec'
/app/vendor/bundle/ruby/2.7.0/gems/railties- `run'
/app/vendor/bundle/ruby/2.7.0/gems/railties- `block in run_initializers'
/app/vendor/bundle/ruby/2.7.0/gems/railties- `run_initializers'
/app/vendor/bundle/ruby/2.7.0/gems/railties- `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- `block in require'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport- `load_dependency'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport- `require'
/app/vendor/bundle/ruby/2.7.0/gems/railties- `require_environment!'
/app/vendor/bundle/ruby/2.7.0/gems/railties- `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- `block in perform'
/app/vendor/bundle/ruby/2.7.0/gems/railties- `perform'
/app/vendor/bundle/ruby/2.7.0/gems/railties- `invoke'
/app/vendor/bundle/ruby/2.7.0/gems/railties- `<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



  • 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

Hey @Florian, and welcome to our community :wave:

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.

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

Could your share the code of the Subscription collection too.

I’ll try to test on my end.

ok i send you a private message with that. Thanks

1 Like

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.

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 :

  "meta": {
    "liana": "forest-rails",
    "liana_version": "7.5.1",
    "stack": {
      "database_type": "postgresql",
      "orm_version": ""

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

 "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 ?

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?

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

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)

ok i am going to try that !

1 Like

We just successfully pushed in Production !!!
Thanks for the help :muscle:
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 ?

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

1 Like