23

I created, using the scaffolding, a model and controller files.
Later I discovered it would be a good idea to create the tables in the DB first...
My question, How can I role back the generated files and regenerate them now, that I have the tables in the DB?

I just started learning RoR, so right now I am not interested in best practices, just learning the tool box this FW (RoR) comes with.

And, do you have a recommendation for a good tutorial? I do know to use google, it is just that search engines don't know, yet (working on that), how to grade tutorials.
Edit: For my last question I found Learning Ruby on Rails

Community
  • 1
  • 1
Itay Moav -Malimovka
  • 52,579
  • 61
  • 190
  • 278

3 Answers3

35

try

rails destroy scaffold XXXXX

one thing that I find puzzling though is that you said "Later I discovered it would be a good idea to create the tables in the DB first..."

Well, rails creates a migration file for you when you run the generator in the first place, and this file will create your DB tables and fields when you run it using rake db:migrate

PS - here's a few good tutorials for you:

stephenmurdoch
  • 34,024
  • 29
  • 114
  • 189
19

You can rollback controller.

rails destroy controller [controller]
Kick Buttowski
  • 6,709
  • 13
  • 37
  • 58
ultrakain
  • 251
  • 3
  • 6
1

You can delete all the files Rails created -- just look at the printout on your command line, see what files rails created, and delete them.

I don't know why you would want to create all the tables in the db, but that's fine, I guess. I prefer to let rails do it. Either way, Rails won't mind. You can always add / change fields using Rails, even if you created the tables outside Rails.

Ryan Bates' Railscasts are excellent tutorials.

fengolly
  • 503
  • 3
  • 8