Skip to content

Customize the list of generated views #422

Closed
@pas256

Description

@pas256

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions