Rails developers all use some or many of these commands like
rails g or rails generate
to run an official or custom generator
rails d or rails destroy
to revert back newly created code/scaffold etc
you all know it well.
rails assets:precompile rails application_record rails assets rails rails rails channel rails controller rails generator rails helper rails integration_test rails jbuilder rails job rails mailer rails migration rails model rails resource rails responders_controller rails scaffold rails scaffold_controller rails serializer rails system_test rails task
And more related to ActiveRecord and Tests.
But there are some more less known/used which can be helpful too in some cases
rails console --sandbox
Any modifications you make will be rolled back on exit of session.
Connects to underlying database using adapter, we can pass environment variable with -e option as we do in
rails c -e production
This command will show following information about our application
Ruby version along with OS
Database schema version
rails stats (My Favorite 🙂 )
Quick summary of the lines of code, lines of test code, number of classes, number of methods, the ratio of methods to classes, and the ratio of lines of code per method.
There is “Code to Test Ratio” at the end of output if that is anything less than 1:1 that is an indication that our application lacks sufficient tests.
Will search form comments you wrote starting with “TODO”, “FIXME” or “OPTIMIZE” in
(.rb, .erb, .rake, .css, .js, .ruby, .yml, .yaml, .bundler) files.
By default this command will only look in the
app, config, db, lib and test directories.
we can configure this by
rails notes #prints all containing any of the words
rails notes:todo #prints only TODO, you can pass any of three
This is useful if you need to know where you want to work later or optimize a code block.
These commands clears all, clears cache only, clears sockets only and clears screenshots only respectively
& The last but not least in the list is
shows all known timezones to rails. That’s all, hope you enjoyed and learned something.
If you know any other, please share in comments I’ll include that here.