Skip to content

Instantly share code, notes, and snippets.

@aellispierce
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aellispierce/a3867c087e20c1bba30b to your computer and use it in GitHub Desktop.
Save aellispierce/a3867c087e20c1bba30b to your computer and use it in GitHub Desktop.
Discuss Rails 2

Detailed Rails Questions

  • What is the difference between form_for and form_tag?

    • form_for is used when you're connecting the form to an instance of a class. For example if you want to save a new instance of the User class you would define @user = User.new and then use "form_for @user." In contrast, form_tag is used when you're not specifically connecting it to any instances of classes.
  • What is the difference between render and redirect_to?

    • Render just shows the page without performing any of the actions in the controller. Redirect_to performs the controller actions and then shows the page.
  • What is the difference between development and production?

    • Development is the environment where you make all of your changes and can do things like make new branches for trying new features. Production is where you push the product when it's ready for others to see or use. Whether it's a final product or an MVP.

Big Picture Questions

  • What do you think about RSpec and MiniTest? Have you used either of them? Which do you think is better?

    • I have used both. I think the syntax of RSpec is better than the syntax of minitest in that it leads you to thinking more in a TDD or BDD way. This can be shown even in small differences in the words they use, whereas Minitest uses the word "assert" (implying that something has already been done), Rspec uses "expect" (making it clear that the test should be written before the code). However, minitest is however much faster than Rspec by default.
  • What do you try to keep in mind when you're designing your models?

    • I try to make sure that any complicated logic that I'll need to do ends up in the model as opposed to letting it spill over to the controller. I also make sure that I have small methods that do one thing, instead of letting myself write very long complicated methods. Additionally, I try to keep in mind basic Object-Oriented principles like the Law of Demeter to ensure that I'm not designing my models in a way that will make them harder to maintain in the future or cause excessive technical debt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment