thoughtbot/administrate

Error when excluding asset paths in application.rb

benjichen16 opened this issue · 2 comments

What were you trying to do?

Was trying to install the administrate gem and run the rails generate administrate:install command to generate some views.

What did you end up with (logs, or, even better, example apps are great!)?

Here is an example application I created:
https://github.com/benjichen16/erroring_app_for_administrate_gem

Inside this app, we have the default rails application and the administrate gem. In the second commit of this repo, I added this line:

config.assets.excluded_paths << "app/assets/application.css"

Which will cause the application to error out with these logs:

$ rails generate administrate:install
/example_app/config/application.rb:21:in `<class:Application>': undefined method `<<' for nil:NilClass (NoMethodError)

    config.assets.excluded_paths << "app/assets/stylesheets/tailwind.css"
                                 ^^
	from example_app/config/application.rb:10:in `<module:ExampleApp>'
	from example_app/config/application.rb:9:in `<main>'
	from </ruby-3.2.1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
	from </ruby-3.2.1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'

I believe this is related to this issue:
#2091

What versions are you running?

  • Rails: Rails 7.0.8
  • administrate: 0.19.0

Hello, I'm here from this tweet

excluded_paths is not on option on config.assets

Options:

) config.assets.methods.sort - Object.methods

[:[], :[]=, :_get, :all?, :any?, :assert_valid_keys, :assoc, :chain, :chunk, :chunk_while, :clear, :collect, :collect_concat, :compact, :compact!, :compact_blank, :compact_blank!, :compare_by_identity, :compare_by_identity?, :configure, :count, :cycle, :deconstruct_keys, :deep_merge, :deep_merge!, :deep_merge?, :deep_stringify_keys, :deep_stringify_keys!, :deep_symbolize_keys, :deep_symbolize_keys!, :deep_transform_keys, :deep_transform_keys!, :default, :default=, :default_proc, :default_proc=, :delete, :delete_if, :detect, :dig, :drop, :drop_while, :each, :each_cons, :each_entry, :each_key, :each_pair, :each_slice, :each_value, :each_with_index, :each_with_object, :empty?, :entries, :except, :except!, :exclude?, :excluding, :extract!, :extractable_options?, :fetch, :fetch_values, :filter, :filter!, :filter_map, :find, :find_all, :find_index, :first, :flat_map, :flatten, :grep, :grep_v, :group_by, :has_key?, :has_value?, :in_order_of, :including, :index_by, :index_with, :inject, :invert, :keep_if, :key, :key?, :keys, :lazy, :length, :many?, :map, :max, :max_by, :maximum, :member?, :merge, :merge!, :method_missing, :min, :min_by, :minimum, :minmax, :minmax_by, :nested_under_indifferent_access, :none?, :one?, :partition, :pick, :pluck, :rassoc, :reduce, :rehash, :reject, :reject!, :replace, :reverse_each, :reverse_merge, :reverse_merge!, :reverse_update, :select, :select!, :shift, :size, :slice, :slice!, :slice_after, :slice_before, :slice_when, :sole, :sort, :sort_by, :store, :stringify_keys, :stringify_keys!, :sum, :symbolize_keys, :symbolize_keys!, :take, :take_while, :tally, :to_a, :to_h, :to_hash, :to_msgpack, :to_options, :to_options!, :to_proc, :to_set, :to_xml, :transform_keys, :transform_keys!, :transform_values, :transform_values!, :uniq, :update, :value?, :values, :values_at, :with_defaults, :with_defaults!, :with_indifferent_access, :without, :zip]

This is not a problem with administrate. This issue happens even if you just try to boot the server:

% bin/rails s    
          
/erroring_app_for_administrate_gem/config/application.rb:21:in `<class:Application>': undefined method `<<' for nil (NoMethodError)

    config.assets.excluded_paths << "app/assets/application.css"

It looks like you're trying to exclude Tailwind (which is weird) but what are you actually trying to do?

Hey - I believe I made a mistake when working on this, and wrongfully blamed administrate (oops). Looking back at this issue, its no longer an issue 👍

Closing