Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Using scaffold along with Active Admin

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 585
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: