Interview questions/answers for an entry level RubyOnRails developer:
Q) What site contains the Rails framework documentation?
Note: When I was starting to learn Rails, there was always a tab open for this site. This is a guess that other developers learning Rails would be utilizing this page as well.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q) What does RAILS_ROOT represent?
A) The base directory for your application.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q) By convention, where are the images for the site stored?
A) RAILS_ROOT/public/images
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q) Where do you put the database connection information?
A) A file named database.yml located in the RAILS_ROOT/config directory.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q) List the directories located under the RAILS_ROOT/app directory.
A) controllers, views, helpers, models
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q) By convention, if my model is named user.rb what will my table name be?
A) The table will be named users. Rails convention is to pluralize table names.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q) What table is used to store the current migration version?
A) schema_info
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q) What’s the command used to run a migration?
A) rake db:migrate
Note: Here are a couple parameters I use often:
- –trace : outputs the process details to the screen. useful for debugging
- VERSION=<num> : set which version this migration should be targeting. needed to roll back your database.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q) Name some built-in validation methods.
A) Here’s a list of the methods I use the most. The full list can be found on the api site.
- validates_presence_of
- validates_uniqueness_of
- validates_length_of
- validates_format_of
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q) What is the helper method to generate an anchor tag?
A) link_to
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q) If I have a controller file RAILS_ROOT/app/controllers/orders_controller.rb where would the orders index.rhtml file be located?
A) RAILS_ROOT/app/views/orders/index.rhtml
Intermediate (201) and Advanced (301) questions will be posted in the coming weeks. I’ll also be updating this post as more questions come to mind.
