component-based-rails-applications-book
component-based-rails-applications-book copied to clipboard
Section 2.1: uninitialized constant ActionText::Engine::ApplicationController
Rails 6.0.0
https://github.com/rails/rails/issues/35749
app
folder con not be removed entirely doing the book on Rails 6, since Zeitwerk autoloading expects app/controllers/application_controller.rb
to be in place.
Without this file, error uninitialized constant ActionText::Engine::ApplicationController
is raised while visiting root
Thanks for letting everyone know!
There is any alternatives to work around and keep /app dir out? I really liked the approach to not have an app place at all. Like you've said in the book: it sends a clear message.
I haven't found a way. We'll leave this issue open so that others coming across this can add to the conversation.
Puma caught this error: uninitialized constant ActionText::Engine::ApplicationController (NameError)
/usr/local/lib/ruby/gems/2.7.0/gems/actiontext-6.0.2.1/lib/action_text/engine.rb:43:in block (2 levels) in <class:Engine>' /usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/callbacks.rb:429:in
instance_exec'
/usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/callbacks.rb:429:in block in make_lambda' /usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/callbacks.rb:201:in
block (2 levels) in halting'
/usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/callbacks.rb:607:in block (2 levels) in default_terminator' /usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/callbacks.rb:606:in
catch'
/usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/callbacks.rb:606:in block in default_terminator' /usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/callbacks.rb:202:in
block in halting'
/usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/callbacks.rb:514:in block in invoke_before' /usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/callbacks.rb:514:in
each'
/usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/callbacks.rb:514:in invoke_before' /usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/callbacks.rb:134:in
run_callbacks'
/usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/execution_wrapper.rb:119:in complete!' /usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/execution_wrapper.rb:76:in
ensure in block in run!'
/usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/execution_wrapper.rb:76:in block in run!' /usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/execution_wrapper.rb:70:in
tap'
/usr/local/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.1/lib/active_support/execution_wrapper.rb:70:in run!' /usr/local/lib/ruby/gems/2.7.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/executor.rb:12:in
call'
/usr/local/lib/ruby/gems/2.7.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/static.rb:126:in call' /usr/local/lib/ruby/gems/2.7.0/gems/rack-2.1.1/lib/rack/sendfile.rb:113:in
call'
#<NameError: uninitialized constant ApplicationController::DeviseWhitelist>
/home/djole/DjoloPortfolio/app/controllers/application_controller.rb:2:in <class:ApplicationController>' /home/djole/DjoloPortfolio/app/controllers/application_controller.rb:1:in
... and so on.. any idea how to fix it?
@djordje21 would you describe a bit more of what's going on in your app?
Are you using devise? Did you delete the default application controller? Are you creating DeviseWhitelist or is that something that's there by default?
@shageman It's my first app and I'm still learning how to fix the bugs and I fixed mine somehow. Yes, I am using Devise, thanks for fast answer.
So, in my application_controller.rb : class ApplicationController < ActionController::Base protect_from_forgery with: :exception include DeviseWhitelist include SetSource end
then I went in my devise_whitelist.rb :
module DeviseWhitelist extend ActiveSupport::Concern
included do
before_action :configure_permitted_parameters, if: :devise_controller?
end
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
devise_parameter_sanitizer.permit(:account_update, keys: [:name])
end
end
At the moment when I post my comment i had instead of before_action there was before_filter but before_filter didn't work, and that was the error message,
I just change it in before_action .
Ok. Cool. Sounds like you are unblocked for now. Let me know if you come across any other issues!
On Wed, Feb 19, 2020 at 11:36 AM, Djordje [email protected] wrote:
@shageman It's my first app and I'm still learning how to fix the bugs and I fixed mine somehow. Yes, I am using Devise, thanks for fast answer.
So, in my application_controller.rb : class ApplicationController < ActionController::Base protect_from_forgery with: :exception include DeviseWhitelist include SetSource end
then I went in my devise_whitelist.rb :
module DeviseWhitelist extend ActiveSupport::Concern
included do before_action :configure_permitted_parameters, if: :devise_controller? end
def configure_permitted_parameters devise_parameter_sanitizer.permit(:sign_up, keys: [:name]) devise_parameter_sanitizer.permit(:account_update, keys: [:name]) end
end
At the moment when I post my comment i had instead of before_action there was before_filter but before_filter didn't work, and that was the error message,
I just change it in before_action .
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
I was able to work around this and the sprockets issues by updating config/application.rb to be
#require 'rails/all' require "rails" require "active_model/railtie" require "active_job/railtie" require "active_record/railtie" require "active_storage/engine" require "action_controller/railtie" require "action_mailer/railtie" require "action_mailbox/engine" #require "action_text/engine" require "action_view/railtie" require "action_cable/engine"
Is there anyway to load only what you need in the top level rails app, and then within each component/engine load only what you need there too? An example would be I wouldn't need Action Text in the top level rails app, but I do need it within certain engines/components?
@mbjornson interesting idea! I have never seen this but think it should be possible:
In the requires that you posted, and only what you know the main app needs. Then in a component and a require to additional stuff at the top of components/your-gem/lib/your-gem.rb
Generally this is the way in which you ensure that gems have access to all their external dependencies.
I'm also working in Rails 6 and got this and the sprockets error, so I've been trying to read as much as possible on engines and I suck at webpack to boot. The app that I'm thinking about using cbra approach is for a product I'm building. So I can't really go back to rails 5... I've been trying to go thru Spree, Devise and RefineryCMS's repos to see how they are approaching these two issues. I'm going to try to use the above approach to see how that works.
I started working through the book with a new Rails 5 app. No issues what so ever. I wonder how many of these issues are due to changes in Rails 6?