Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Task rails generate binda:setup is broken (undefined method `choices') #228

Open
a-barbieri opened this issue May 16, 2019 · 11 comments · Fixed by #227
Open

Task rails generate binda:setup is broken (undefined method `choices') #228

a-barbieri opened this issue May 16, 2019 · 11 comments · Fixed by #227

Comments

@a-barbieri
Copy link
Collaborator

Issue

It's not possibile to complete setup.

Expected behavior

Should complete the setup as usual.

How to reproduce the issue

  1. rails db:drop && rails db:create
  2. rails generate binda:install

Returns this error:

Traceback (most recent call last):
    18: from bin/rails:4:in `<main>'
    17: from bin/rails:4:in `require'
    16: from /Users/lorenzo/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/railties-5.2.1/lib/rails/commands.rb:18:in `<top (required)>'
    15: from /Users/lorenzo/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/railties-5.2.1/lib/rails/command.rb:46:in `invoke'
    14: from /Users/lorenzo/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/railties-5.2.1/lib/rails/command/base.rb:65:in `perform'
    13: from /Users/lorenzo/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
    12: from /Users/lorenzo/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
    11: from /Users/lorenzo/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
    10: from /Users/lorenzo/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/railties-5.2.1/lib/rails/commands/generate/generate_command.rb:26:in `perform'
     9: from /Users/lorenzo/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/railties-5.2.1/lib/rails/generators.rb:276:in `invoke'
     8: from /Users/lorenzo/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
     7: from /Users/lorenzo/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/group.rb:232:in `dispatch'
     6: from /Users/lorenzo/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `invoke_all'
     5: from /Users/lorenzo/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `map'
     4: from /Users/lorenzo/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `each'
     3: from /Users/lorenzo/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `block in invoke_all'
     2: from /Users/lorenzo/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
     1: from /Users/lorenzo/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
/Users/lorenzo/Sites/binda/lib/generators/binda/setup/setup_generator.rb:47:in `setup_maintenance_mode': undefined method `choices' for nil:NilClass (NoMethodError)

System configuration

Binda version: 0.1.11

Rails version: 5.2

@a-barbieri
Copy link
Collaborator Author

The issue is related to the new ActiveJob feature.

This feature runs at every after_save of FieldSetting model the function is called create_field_instances. See this line

It'd be great if it was possible to add a callback to this ActiveJob and pass it as a parameter. The problem is that I don't think it can be done via the after_save callback.

Refer to this piece of code.
https://github.com/BindaCMS/binda/blob/master/app/models/binda/field_setting.rb#L247-L260

@tau9
Copy link
Contributor

tau9 commented May 16, 2019

@Marchino is config.active_job.queue_adapter = :async the only configuration needed to complete the Active Job integration?
I think something is missing in the merge request description/code, maybe an after_perform callback like the above suggestion by Alessandro?
I have no experience with Active Job but with a hint maybe I can investigate better this issue.

@a-barbieri
Copy link
Collaborator Author

@thauma9 After digging more on the subject I have come to the conclusion that there is no way to know what's the state of the cue when you are using the default cue adapter (:inline). Therefore you cannot know if your component has been updated unless you are polling a function that checks it.

I can see two possible solutions:

  1. We move the optimisation to a plugin where you are asked to use a backend (Rescue, Sidekiq, or similar), this way you don't have to put Sidekiq as a dependency, but if you like you can add that plugin.
  2. We make the component aware that is going to be updated adding a state updating which is stored in the database.

@Marchino, any suggestion?

@Marchino
Copy link
Contributor

Marchino commented May 24, 2019 via email

@a-barbieri
Copy link
Collaborator Author

a-barbieri commented May 24, 2019

One easy way to fix this problem might be to force config.active_job.queue_adapter to :inline

I'm currently not setting any queue_adapter which means I'm using :inline(Rails default adapter), but it throws an error.

My guess is that the application doesn't wait for the job to finish even though is :inline.

Can you confirm you can reproduce the same issue?

@Marchino
Copy link
Contributor

Marchino commented May 24, 2019 via email

@a-barbieri
Copy link
Collaborator Author

a-barbieri commented May 24, 2019 via email

@Marchino
Copy link
Contributor

Marchino commented May 24, 2019 via email

@a-barbieri
Copy link
Collaborator Author

a-barbieri commented May 25, 2019 via email

@Marchino
Copy link
Contributor

Marchino commented May 25, 2019 via email

@a-barbieri
Copy link
Collaborator Author

This is interesting. Always astonished to find how much I can still learn from you! 😛

I'll give it a try.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants