If we are incorporating Active Admin,a gem that provides a full-fledged admin panel,with our rails application,then a common anomaly encountered is ,scaffold command won't be giving out desired results.
The basic feature of scaffold is to provide CRUD operations for the controller specified ,but,when our application is using Active Admin gem ,the controller inherits InheritedResouces : : Base instead of ApplicationController.
Now ,in order to fix this issue ,there are two options.
first being,simply add the following line to config/application.rb file
config.app_generators.scaffold_controller = :scaffold_controller
Now,Its implication is that scaffold command provides us normal controller having CRUD operations and inheriting ApplicationController.
Second way forward is to explicitly mention while writing the scaffold command in the console that we want " The Normal Controller" for this particular model. like this
rails g scaffold User name:string -c=scaffold_controller
Now,the UsersController inherits ApplicationController instead of InheritedResources::Base .
Having provided both the options,the majority of us gets a feeling that it's better to make changes in the setting file rather than typing -c=scaffold_controller flag with each scaffold command.
Thanks for reading.
0 Comment(s)