Skip to content

Instantly share code, notes, and snippets.

@vidkun
Last active August 29, 2015 14:06
Show Gist options
  • Save vidkun/517846661a37068a1b15 to your computer and use it in GitHub Desktop.
Save vidkun/517846661a37068a1b15 to your computer and use it in GitHub Desktop.
  1. What does MVC stand for?
  • Model View Controller
  1. What is the purpose of MVC?
  • Decoupling of duties within the application
  1. What is the command you would use to generate a new rails application called "twitter"?
  • rails new twitter
  1. Which file do you edit to add additional gems to your rails app?
  • Gemfile
  1. What is the purpose of .gitignore file?
  • Instruct git to ignore certain files you don't want tracked
  1. What is the app/assets folder used for?
  • Storing your app's assets (JS, stylesheets, images, etc)
  1. What is the vendor/assets folder used for?
  • Storing assets used within your app that are provided by a third-party
  1. What is the command to create my initial database?
  • rake db:create
  1. What is the name of the file where I define my home page url?
  • config/routes.rb
  1. What does Rails.env return when developing locally?
  • development
  1. What does Rails.root return when developing locally?
  • the path to your app's root directory.
  1. What is the command you use to do irb with the rails application preloaded for you?
  • rails console
  1. What is the command to create a new model called Tweet with a message string?
  • rails g model Tweet message
  1. What is the command to update your database with changes?
  • rake db:migrate
  1. What is the purpose of migrations?
  • to apply changes to the database schema
  1. What is the job of the controller?
  • control the flow of data within the application. Tells the model what to do/provide and tells the view what to present to the user
  1. What is the command to generate a controller called tweets?
  • rails g controller tweets
  1. Define a route for showing all the tweets in our controller and a route for showing a specific tweet:
  • get '/tweets', to: 'tweets#index', as: tweets
  • get 'tweets/:id', to: 'tweets#show', as: tweet
  1. What is the default view templating engine in rails?
  • erb
  1. What is the code to validate a tweet's message is reqired when making a new tweet?
  • validates :message, presence: true
  1. What does REST stand for?
  • representational state transfer
  1. What is the purpose of rake?
  • to serve as a replacement for make and makefiles. it provides a means of performing common administrative tasks related to your application such as managing your db, etc.
  1. What folder can we use in our rails app to define custom rake tasks?
  • lib/tasks
  1. In rails, the method number_to_currency is a what?
  • helper
  1. In rails, when using a relational database, all models inherit from what class?
  • ActiveRecord::Base
  1. What is the command to create a new migration file for adding location to a tweet?
  • rails g migration add_location_to_tweet location
  1. 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
  1. In SQL, how would I query for the number of records in my tweets table?
  • select count(id) from tweets;
  1. In rails, how would I query for the number of records in my Tweet model?
  • Tweet.count
  1. What is the command to start your rails application?
  • rails server
  1. What port does your rails application run on by default locally?
  • 3000
  1. Name 3 types of database associations:
  • belongs_to, has_many, has_many_through
  1. What is params?
  • refers to the parameters passed to application in a web request
  1. What is flash?
  • a nice helpful way of storing and presenting errors and notices to the user when they do something that warrants it (usually something stupid)
  1. Where would you write a custom helper method?
  • app/helpers
  1. What is the SQL code for finding all tweets where the location is equal to "Salt Lake"?
  • select * from tweets where location = 'Salt Lake';
  1. What is the rails code for finding all tweets where the location is equal to "Salt Lake"?
  • Tweet.where(location: 'Salt Lake')
  1. What is the rails code for finding only a max of 5 tweets where the location begins with "Salt Lake"?
  • Tweet.where("location LIKE ?", 'Salt Lake%').limit(5)
  1. When using a secific query over and over it's best to make it into a method. What type of method do we use?
  • scope
  1. I have this route tweet GET /tweets/:id(.:format) tweets#index. What two helper methods can I use?
  • link_to, button_to
  1. What does the parenthesis in a route denote?
  • optional parameters
  1. What do the symbols in a route mean?
  • parameters that are passed in during the request
  1. All pages use which HTTP verb?
  • GET and/or HEAD
  1. Which helper method will create an html anchor tag for us?
  • link_to
  1. Which helper method will create an html form tag for us?
  • form_tag and form_for
  1. Which helper method will create an html password field for us?
  • password_field
  1. The instance variable @tweets can most likely be used like what data type?
  • array of objects
  1. What construct can we use in a view to write ruby code?
  • embedded ruby, erb
  1. What is the code to iterate over a @tweets variable in a view?
  • <% @tweets.each do |tweet| %>
  • <%= tweet.do_stuff %>
  • <% end %>
  1. What is the method to save a newly created record to the database in rails?
  • save
  1. What is the method to remove a record from the database in rails?
  • destroy
  1. What is the method to update some of the attributes of an object in rails?
  • update
  1. Aside from a tweet, what other model could twitter possibly use?
  • user
  1. What is the command to see all of the urls defined in my rails application?
  • rake routes
  1. What file do I use to update the styles for my application?
  • any of the stylesheets under app/assets/stylesheets; by default: application.css(.scss)
  1. Is your brain hurting yet?
  • not really, but my arms are
  1. What is the current version of rails?
  • 4.1.6
  1. When was rails created?
  • July 2004
  1. Who created rails?
  • David Heinemeier Hansson
  1. What is the purpose of scaffolding?
  • to be lazy and have basic common pieces automagically generated for you all at once (such as: model, controller, routes, tests, migrations, etc)
  1. What is a partial?
  • sections of code to be shared across multiple views.
  1. How can you tell a file is a partial?
  • filename is prefixed with an underscore
  1. PostgeSQL is what type of database?
  • relational
  1. Name another database engine similar to PostgreSQL.
  • MySQL
  1. Name a database engine that is a different type from PostgreSQL:
  • NoSQL, Cassandra
  1. Are you ready for the last question?
  • yes. this isn't interesting anymore
  1. What is a foreign key used for?
  • linking associations across different tables within a database
  1. Did you really think question 67 was the last?
  • no
  1. What method in the the routes file do I use to define my home page?
  • root
  1. What does SASS stand for?
  • Syntactically Awesome Style Sheets
  1. What is SASS used for?
  • making CSS suck less
  1. What gem group would you put pry-rails into?
  • development
  1. How would you create a static "about" page? i.e. what steps would be needed?
  • quick and dirty way: create a static_pages controller with an 'about' action to render the 'about.html.erb' view.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment