Skip to content

Customize the list of generated views #425

Closed Answered by pas256
pas256 asked this question in Q&A
Discussion options

You must be logged in to vote

Yeah it is possible. Well, sort of.

I was following this: https://gist.github.com/annikoff/331f785aa7a207a7945b1eca6eff526b to add pundit policy generation to my scaffolding. The technique it uses is to make a hooks.rb file that does the monkey patching.

... however the approach of requireing inside of the generator config in config/application.rb felt weird, and ended up causing the active_record generator to be skipped. ¯\_(ツ)_/¯

This morning I have abandon that approach and went back to subclassing as you suggested. I have a working solution, and I am mostly happy with it, but it does have more duplicated code than is strictly necessary.

First, override the scaffold_controller generator:

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@pas256
Comment options

Answer selected by pas256
@flavorjones
Comment options

@pas256
Comment options

@flavorjones
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #422 on October 18, 2024 13:29.