rails / jbuilder

Jbuilder: generate JSON objects with a Builder-style DSL
MIT License
4.33k stars 430 forks source link

I am moving my rails application to rails only api but jbuilder is returning a blank screen #541

Open hassanrbh opened 1 year ago

hassanrbh commented 1 year ago

I check all of the previous talks about the same problem , I suppose to solve it with include ActionView::Rendering but when I include it, I get a different error saying undefined method 'include?"

/Users/mac/.rvm/gems/ruby-2.7.0/gems/actionpack-6.1.4.1/lib/abstract_controller/helpers.rb:148:in block in helper': undefined methodinclude?' for nil:NilClass (NoMethodError)

class ApplicationController < ActionController::API include ActionController::RequestForgeryProtection include JSONAPI::ActsAsResourceController include ActionController::Helpers include ActionController::Cookies include ActionController::ImplicitRender include ActionView::Rendering

protect_from_forgery unless: -> { request.format.json? || request.format.xml? } after_action :flash_to_headers before_action :store_current_location, :unless => :devise_controller? before_action :flow_filter before_action :configure_permitted_parameters, if: :devise_controller? before_action :check_temporary_user, if: :devise_controller? before_action :authenticate_and_set_user before_action :authenticate_author_sdk before_action :authorize_user_or_author_access_token? before_action :underscore_params! respond_to :json end

hassanrbh commented 1 year ago

there is no one to response ?

hahmed commented 1 year ago

@hassanrbh could you provide more information about the issue you are facing? Ideally a repo that shows the problem... there is not enough to go by to comment on what's going wrong

p8 commented 1 year ago

Looking at the source of the error it seems _helpers is nil. https://github.com/rails/rails/blob/6-1-stable/actionpack/lib/abstract_controller/helpers.rb#L148 Could you post the whole backtrace of the error?

hassanrbh commented 1 year ago

@p8 yeah sure dude, one minute

hassanrbh commented 1 year ago

@p8 her is it Traceback (most recent call last): 95: from bin/rails:4:in <main>' 94: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:inrequire' 93: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in require_with_bootsnap_lfi' 92: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:inregister' 91: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in block in require_with_bootsnap_lfi' 90: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:inrequire' 89: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/commands.rb:18:in <main>' 88: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/command.rb:48:ininvoke' 87: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/command/base.rb:69:in perform' 86: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/thor-1.1.0/lib/thor.rb:392:indispatch' 85: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in invoke_command' 84: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/thor-1.1.0/lib/thor/command.rb:27:inrun' 83: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/commands/server/server_command.rb:135:in perform' 82: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/commands/server/server_command.rb:135:intap' 81: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/commands/server/server_command.rb:144:in block in perform' 80: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/commands/server/server_command.rb:37:instart' 79: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/commands/server/server_command.rb:77:in log_to_stdout' 78: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/rack-2.2.3/lib/rack/server.rb:422:inwrapped_app' 77: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/rack-2.2.3/lib/rack/server.rb:249:in app' 76: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/rack-2.2.3/lib/rack/server.rb:349:inbuild_app_and_options_from_config' 75: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/rack-2.2.3/lib/rack/builder.rb:66:in parse_file' 74: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/rack-2.2.3/lib/rack/builder.rb:105:inload_file' 73: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in new_from_string' 72: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/rack-2.2.3/lib/rack/builder.rb:116:ineval' 71: from config.ru:3:in block in <main>' 70: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:inrequire' 69: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:299:in load_dependency' 68: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:inblock in require' 67: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in require' 66: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:inrequire_with_bootsnap_lfi' 65: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in register' 64: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:inblock in require_with_bootsnap_lfi' 63: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in require' 62: from /Users/mac/Desktop/work/inara-dev/config/environment.rb:5:in

' 61: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/application.rb:391:in initialize!' 60: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:60:inrun_initializers' 59: from /Users/mac/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/tsort.rb:205:in tsort_each' 58: from /Users/mac/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/tsort.rb:226:intsort_each' 57: from /Users/mac/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/tsort.rb:347:in each_strongly_connected_component' 56: from /Users/mac/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/tsort.rb:347:incall' 55: from /Users/mac/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/tsort.rb:347:in each' 54: from /Users/mac/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/tsort.rb:349:inblock in each_strongly_connected_component' 53: from /Users/mac/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/tsort.rb:431:in each_strongly_connected_component_from' 52: from /Users/mac/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/tsort.rb:350:inblock (2 levels) in each_strongly_connected_component' 51: from /Users/mac/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/tsort.rb:228:in block in tsort_each' 50: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:61:inblock in run_initializers' 49: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:32:in run' 48: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:32:ininstance_exec' 47: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/application/finisher.rb:134:in block in <module:Finisher>' 46: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/application/finisher.rb:134:ineach' 45: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:358:in eager_load!' 44: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:489:ineager_load!' 43: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:489:in each' 42: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:492:inblock in eager_load!' 41: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:492:in each' 40: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/railties-6.1.4.1/lib/rails/engine.rb:493:inblock (2 levels) in eager_load!' 39: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:288:in require_dependency' 38: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:375:independ_on' 37: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:402:in require_or_load' 36: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:39:inload_interlock' 35: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies/interlock.rb:13:in loading' 34: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/concurrency/share_lock.rb:151:inexclusive' 33: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies/interlock.rb:14:in block in loading' 32: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:39:inblock in load_interlock' 31: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:419:in block in require_or_load' 30: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:522:inload_file' 29: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:715:in new_constants_in' 28: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:523:inblock in load_file' 27: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in load' 26: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:inload' 25: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/devise-4.8.0/app/controllers/devise/confirmations_controller.rb:3:in <main>' 24: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:213:inconst_missing' 23: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:558:in load_missing_constant' 22: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:402:inrequire_or_load' 21: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:39:in load_interlock' 20: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies/interlock.rb:13:inloading' 19: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/concurrency/share_lock.rb:151:in exclusive' 18: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies/interlock.rb:14:inblock in loading' 17: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:39:in block in load_interlock' 16: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:419:inblock in require_or_load' 15: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:522:in load_file' 14: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:715:innew_constants_in' 13: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:523:in block in load_file' 12: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:inload' 11: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in load' 10: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/devise-4.8.0/app/controllers/devise_controller.rb:4:in
' 9: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/actionview-6.1.4.1/lib/action_view/layouts.rb:219:in inherited' 8: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/actionpack-6.1.4.1/lib/action_controller/railties/helpers.rb:7:ininherited' 7: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/actionpack-6.1.4.1/lib/abstract_controller/railties/routes_helpers.rb:9:in block (2 levels) in with' 6: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/actionpack-6.1.4.1/lib/abstract_controller/helpers.rb:51:ininherited' 5: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/actionpack-6.1.4.1/lib/abstract_controller/helpers.rb:51:in class_eval' 4: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/actionpack-6.1.4.1/lib/abstract_controller/helpers.rb:51:inblock in inherited' 3: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/actionpack-6.1.4.1/lib/abstract_controller/helpers.rb:204:in default_helper_module!' 2: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/actionpack-6.1.4.1/lib/abstract_controller/helpers.rb:147:inhelper' 1: from /Users/mac/.rvm/gems/ruby-2.7.0/gems/actionpack-6.1.4.1/lib/abstract_controller/helpers.rb:147:in each' /Users/mac/.rvm/gems/ruby-2.7.0/gems/actionpack-6.1.4.1/lib/abstract_controller/helpers.rb:148:inblock in helper': undefined method `include?' for nil:NilClass (NoMethodError)