rails/tailwindcss-rails

Customize the list of generated views

pas256 opened this issue · 0 comments

pas256 commented

I would like to add 1 more view to get generated by rails g scaffold so I can have a views/_list_item.rb file.

If I could modify available_views in scaffold_generator.rb I would be able to accomplish this, but unfortunately it is private and not customizable.

I started trying to monkey patch the file by doing something like this

require 'tailwindcss-rails/generators/tailwindcss/scaffold/scaffold_generator'

Tailwindcss::Generators::ScaffoldGenerator.available_views = %w[index edit show new _form _list_view]

but unlike the rails generators where I can do this for generating pundit policies

require 'rails/generators'
require 'rails/generators/rails/scaffold/scaffold_generator'

# Invoke with scaffolding generators
Rails::Generators::ScaffoldGenerator.hook_for :policy, default: true, type: :boolean

this one raises a LoadError and I can't figure out why.

I know this isn't a discussion forum, but any guidance would be greatly appreciated. I feel dumb for not figuring this out. Thanks!