Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby On Rails Design Question: What if I make a mistake? [closed]

I still learning Ruby on Rails, but have been wondering what happens if I make a mistake. For example, if I scaffold and make a typo, what do I do? If I don't do scaffolding, generate a model, rake db:migrate it and find out I need to ad a column or delete one, what do I do? Is it better sometimes to use a third party manager on the database instead of letting RoR do it all? I'm not sure how to feel about designing with RoR. I can't be perfect with it every time!

Thanks

like image 658
johnny Avatar asked Jan 28 '26 13:01

johnny


1 Answers

There's typically a way to fix any issues in rails as long as you know how to do it. you can create new migrations to fix old ones, or rollback the database and change the original migration. All of the rails generate functions also have destroy functions as well. If you mess up a scaffold and catch it right away, just destroy it and do it again. For example, in rails 3:

rails generate model ModelName

can be reversed with

rails destroy model ModelName

in rails < 3 the syntax is ruby script/generate and ruby script/destroy respectively. Google how to reverse migrations. Let rails do the hard work for you, no point in reinventing the wheel with a third party app.

As for version control, LEARN IT. I had no idea how to use git when I started and it's saved my butt more times than I can count. Setup an account with github, it makes learning git SUPER easy.

When you get stuck, trust stackoverflow. People here are really helpful and never judgmental. Great resource for beginners and pros alike!

like image 50
Ryan Avatar answered Jan 30 '26 02:01

Ryan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!