any way to permit 'rails scaffold' to work normally if inherited_resources used by another gem?
I installed ActiveAdmin, which uses InheritedResources, which now means when I try to generate plain old rails scaffolding, it does not create CRUD actions and creates a controller based on InheritedResources.
For those of us who need the ability to create normal rails scaffolds, is there a way to have inherited_resources NOT override the default scaffolding when we manually scaffold new models?
This is how InheritedResources changes this configuration.
You should be able to do the same in your app, configuring back to the default :scaffold_controller, by adding this to your application.rb file:
config.app_generators.scaffold_controller = :scaffold_controller
That should work.
Though that did not work. I tried adding
config.app_generators.scaffold_controller = :scaffold_controller
to config/application.rb, then to config/environments/development.rb. In both cases, running 'rails g scaffold' produced the same empty controller with a class based on InheritedResources::Base instead of ApplicationController
here is something that does work, although it would be much better to change the setting once in a config file per your suggestion, if we can find the right setting. But for a manual override, this works:
rails g scaffold Foobar name:string -c=scaffold_controller
If anyone knows how to revert to scaffold_controller being the default, please chime in.
Weird, setting the config in your application should have worked fine. Could you please send which Rails and IR (or ActiveAdmin) version you're using?
I have rails 3.1.3, IR gem 1.2.2, activeadmin gem 0.3.4, running on windows xp sp3, doing everything via bash shell. rake is 0.8.7.
Bump. I am having the same issue.
It seemed fixed now. Using rails 3.2.1 , activeadmin 0.4.0. Add the line to application.rb got it fixed.
Thanks. I was using rails 3.1.x. Upgrading fixed it.
In Rails 4 this still works.
Hey guys, I'm using Rails 5.2 and ruby 2.5.1 and when running the scaffold generator like rails g scaffold agreement folio customer:references. I still getting my controller inheriting from InheritedResources::Base.
Does this fix config.app_generators.scaffold_controller = :scaffold_controller will be part of the RubyGems version for ActiveAdmin?
Or is it better to use the AA git version?
Hola chicos, estoy usando Rails 5.2 y ruby 2.5.1 y cuando ejecuto el generador de andamios como
rails g scaffold agreement folio customer:references. Todavía tengo mi controlador heredado deInheritedResources::Base.¿Esta solución
config.app_generators.scaffold_controller = :scaffold_controllerserá parte de la versión de RubyGems para ActiveAdmin? ¿O es mejor usar la versión git AA?
Yes.
@jpwynn's solution to use -c=scaffold_generator works like a charm even in Rails 6. Thank you very much!
-c=scaffold_generator didn't work for me, but placing this config line into my app:
config.app_generators.scaffold_controller = :scaffold_controller
and running:
rails g scaffold report start_at:date end_at:date portfolio_name:string -c=scaffold_controller
did work. It's very frustrating that ActiveAdmin breaks Rails default scaffold by doing this.
@KelseyDH I think you have to use either one or the other but not both fixes together.
The config file fix is a one-time fix, once you set that up you do not need to do anything else for each and every scaffold you want to create.
config.app_generators.scaffold_controller = :scaffold_controller
The command-line argument/flag is meant for overriding the app configuration only once for the actual command that you are running at that time. That means that you need to add that flag to your scaffold generator command every single time you run it.
rails g scaffold report start_at:date end_at:date portfolio_name:string -c=scaffold_controller
rails g scaffold url domain:string -c=scaffold_controller
rails g scaffold user name:string -c=scaffold_controller
...
That's why I should recommend to go with the config file and forget about any further flag on the command-line.
what about existing scaffolds? old scaffolds are not working after installing activeadmin even if i use config.app_generators.scaffold_controller = :scaffold_controller
What do you mean by existing scaffolds, old scaffolds ?