Skip to content

Instantly share code, notes, and snippets.

@lcbunch
Last active August 29, 2015 14:02
Show Gist options
  • Save lcbunch/f2ba88da396c03558af0 to your computer and use it in GitHub Desktop.
Save lcbunch/f2ba88da396c03558af0 to your computer and use it in GitHub Desktop.
  1. What does MVC stand for? minimal viable product

  2. What is the purpose of MVC? find the core essentials of app

  3. What is the command you would use to generate a new rails application called "twitter"? rails new twitter -d postgresql

  4. Which file do you edit to add additional gems to your rails app? Gemfile

  5. What is the purpose of .gitignore file? to exclude file from being pushed to github

  6. What is the app/assets folder used for? it holds content owned by the application in the form of images, JS, and css

  7. What is the vendor/assets folder used for? to hold content outside of the application such as code for JS plugins or css

  8. What is the command to create my initial database? rake db:create

  9. What is the name of the file where I define my home page url? routes.rb

  10. What does Rails.env return when developing locally? "development"

  11. What does Rails.root return when developing locally? the folder path

  12. What is the command you use to do irb with the rails application preloaded for you? rails c

  13. What is the command to create a new model called Tweet with a message string? rails g model Tweet message (i think string is defaulted right?)

  14. What is the command to update your database with changes? rake db:migrate

  15. What is the purpose of migrations? to take files from your console to the database

  16. What is the job of the controller? to relay information from the Models to the views

  17. What is the command to generate a controller called tweets? rails g controller Tweets

  18. Define a route for showing all the tweets in our controller and a route for showing a specific tweet: <%= @tweets.each do |tweet| %> <%= link_to(tweet.name) %>

    <%= link_to(tweet.name, tweet_path(tweet.id)) %>

  19. What is the default view templating engine in rails? erb

  20. What is the code to validate a tweet's message is reqired when making a new tweet? validates :name, presence: true

  21. What does REST stand for? representational state transfer

  22. What is the purpose of rake? it is a tool that can preform tasks in rails; we use many predefined tasks

  23. What folder can we use in our rails app to define custom rake tasks? lib -> tasks

  24. In rails, the method number_to_currency is a what? helper method

  25. In rails, when using a relational database, all models inherit from what class? I thought models were classes, i'm confused!

  26. What is the command to create a new migration file for adding location to a tweet? rails generate migration AddLocation location:string

  27. In a migration file, what is the code to add a string location to the tweets table? def change add_column : :tweets, :location, :string end

  28. In SQL, how would I query for the number of records in my tweets table?

  29. In rails, how would I query for the number of records in my Tweet model?

  30. What is the command to start your rails application? rails s

  31. What port does your rails application run on by default locally? localhost:3000

  32. Name 3 types of database associations: relational, hierarchial, object-oriented

  33. What is params? a way to retrieve user specified data

  34. What is flash? a way to pass temporary objects between actions; great for notices and alerts

  35. Where would you write a custom helper method? application_controller.rb

  36. What is the SQL code for finding all tweets where the location is equal to "Salt Lake"? select * from tweets where location='Salt Lake';

  37. What is the rails code for finding all tweets where the location is equal to "Salt Lake"? Tweet.where("location='Salt Lake'")

  38. What is the rails code for finding only a max of 5 tweets where the location begins with "Salt Lake"? @tweets = Tweet.where("location='Salt Lake'").per[5]

  39. When using a secific query over and over it's best to make it into a method. What type of method do we use? private

  40. I have this route tweet GET /tweets/:id(.:format) tweets#index. What two helper methods can I use? debug collection_select

  41. What does the parenthesis in a route denote? a helper i think

  42. What do the symbols in a route mean? it shows what to call upon

  43. All pages use which HTTP verb? GET

  44. Which helper method will create an html anchor tag for us? link_to

  45. Which helper method will create an html form tag for us? form_tag

  46. Which helper method will create an html password field for us? password_field_tag

  47. The instance variable @tweets can most likely be used like what data type? hash

  48. What construct can we use in a view to write ruby code? erb tags <% %> <%= %>

  49. What is the code to iterate over a @tweets variable in a view? <% @tweets.each do |tweet| %>

  50. What is the method to save a newly created record to the database in rails? .save

  51. What is the method to remove a record from the database in rails? .destroy

  52. What is the method to update some of the attributes of an object in rails? update_attribute

  53. Aside from a tweet, what other model could twitter possibly use? User

  54. What is the command to see all of the urls defined in my rails application? ?

  55. What file do I use to update the styles for my application? application.css

  56. Is your brain hurting yet? ja

  57. What is the current version of rails? 2.1.2

  58. When was rails created? 2004

  59. Who created rails? David Hansson

  60. What is the purpose of scaffolding? to do quick and dirty app building for planning purposes

  61. What is a partial? a partial file lets you organize and reuse view code

  62. How can you tell a file is a partial? if it starts with _ and ends with .html.erb

  63. PostgeSQL is what type of database? relational

  64. Name another database engine similar to PostgreSQL. MySQL

  65. Name a database engine that is a different type from PostgreSQL: NoSQL

  66. Are you ready for the last question? :P

  67. What is a foreign key used for? used to add a column from one table to another

  68. Did you really think question 67 was the last? :P

  69. What method in the the routes file do I use to define my home page? root 'homepage#index'

  70. What does SASS stand for? syntactically awesome style sheets

  71. What is SASS used for? it is used to treat css more like a language and then convert it back to css

  72. What gem group would you put pry-rails into? :development

  73. How would you create a static "about" page? i.e. what steps would be needed? create a new controller call is something like site, give it an index and about view add get '/about' => 'site#about' to the routes.rb file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment