Ruby On Rails Design Question: What if I am wrong?

I'm still learning Ruby on Rails, but wondered what would happen if I made a mistake. For example, if I tint and make a typo, what should I do? If I’m not involved in scaffolding, create a model, rake db: transfer it and find out that I need to declare a column or delete it, what should I do? Is it sometimes better to use a third-party manager in the database instead of letting RoR do all this? I'm not sure how to relate to design with RoR. I can't be perfect with him every time!

thanks

+4
source share
3 answers

As a rule, you can solve any problems in the rails, as long as you know how to do it. You can create new migrations to fix old ones or roll back the database and change the initial migration. All rail generation functions also have destruction functions. If you ruin the scaffold and immediately catch it, just destroy it and do it again. For example, in rails 3:

rails generate model ModelName 

can be changed to

 rails destroy model ModelName 

on rails <3, the syntax is ruby ​​script / generate and ruby ​​script / destroy, respectively. Google how to cancel the migration. Let the rails do the hard work for you, no need to reinvent the wheel with a third-party application.

Regarding version control, LEARN THIS. I had no idea how to use git when I started, and it saved my ass more than once I can take it. Set up your account with github, this makes learning git SUPER easier.

When you get stuck, trust stackoverflow. People here are very helpful and never blame. A great resource for beginners and professionals!

+6
source

Use a control source. If you make a mistake, simply discard the changes and all generated files will disappear.

When migrating, if you make a mistake in your development environment, just drop the database, edit the wrong files, and reconfigure the database. You really need to worry about the integrity of the migration after they go into production or are transferred to the other side.

0
source

I suggest git for local source control. Especially generators do a lot of work; you must use a safe line. git gives you this without the hassle - and you don't need a server.

  • git init - create a local repository in .git
  • git commit -a -m "message" - commits changes
  • git reset (--hard) master - returns the last commit

There are good introductions on github.com and on http://gitready.com .

0
source

All Articles