I have, many times, messed up a
rails generate command. For example, using
singular where plural is needed or the reverse.
Today, I learned that you can undo a generate by using
rails destroy with
the same arguments you used for the generate command.
rails generate controller article # Oops! rails destroy controller article rails generate controller articles
Apparently only a few of us in class knew about this during this class.
I’d worked around not knowing this by using
git to commit everything and
then reverting everything if I messed up.
Why doesn’t a generate command show a message explaining that it can be undone with destroy? It’d be really really helpful.
I also discovered you can “redo” the last migration as well, which is really handy as well for repairing mistakes:
thank you very much! i also found it in rails guides
d for short, enjoy it
Im just starting and this is the first question I asked! Thank You!
Thanks it worked
I was doing a video with a instructor and I misspelled the name for the generator, this allowed me to delete it so I could spell it right. Thank you a ton, I just hit this problem and found this solution within 60 seconds.