Nice ! administrate is smart enough to tell us what actually changed. That will produce the following output : route namespace :admin doĬreate app/controllers/admin/application_controller.rbĬreate app/dashboards/author_dashboard.rbĬreate app/controllers/admin/authors_controller.rbĬreate app/dashboards/micropost_dashboard.rbĬreate app/controllers/admin/microposts_controller.rb Now ask administrate to generate a skeleton. Once installed, I suggest to always commit changes before any new file generation, thus, it's far easier to see what and why (bad or good) surprises happen. Then modify models as follow : # Inside app/models/Authors.rb Migrate the database : bin/rails db:migrate Not quite yet like real-world apps, but certainly more than a "hello world" tutorial. Moreover, our Micropost has a boolean, and a reference to the Author. Our Author has :text, :string, :integer, :time and :date types, plus the :datetime type (Rails already brings it to us thanks to timestamps). bin/rails generate model Author name:string email:string bio:text favorite_number:integer awake:time birthday:date -no-test-frameworkīin/rails generate model Micropost name:string content:text published:boolean author:references -no-test-framework In order to see how good the administrate gem is, we need some complex enough models, a single table with a single string-based attribute will not reflect real-world, production-ready web applications. You can also open in your browser, the official repository here, and the docs here, it will be helpful. You have now a fresh, new, default Rails 7 app installed in the "myapp" directory - this is also the name of the tiny app, perfect for a tutorial. Now open your usual workspace, and type mkdir myadmin & cd myadmin Ruby 3.0.0p0 // you need at least version 3 hereĨ.3.0 // you need at least version 7.1 here every file your admin dashboard rely on, can be fully overridden by the developer. It's often qualified as DSL-less admin builder, i.e. Rails administrate : big tutorial, bits of philosophyĪdministrate is a gem that allows you to build an admin dashboard.
0 Comments
Leave a Reply. |