- What does
MVC
stand for?
- Model View Controller
- What is the purpose of
MVC
?
- Decoupling of duties within the application
- What is the command you would use to generate a new rails application called "twitter"?
- rails new twitter
- Which file do you edit to add additional gems to your rails app?
- Gemfile
- What is the purpose of
.gitignore
file?
- Instruct git to ignore certain files you don't want tracked
- What is the
app/assets
folder used for?
- Storing your app's assets (JS, stylesheets, images, etc)
- What is the
vendor/assets
folder used for?
- Storing assets used within your app that are provided by a third-party
- What is the command to create my initial database?
- rake db:create
- What is the name of the file where I define my home page url?
- config/routes.rb
- What does
Rails.env
return when developing locally?
- development
- What does
Rails.root
return when developing locally?
- the path to your app's root directory.
- What is the command you use to do irb with the rails application preloaded for you?
- rails console
- What is the command to create a new model called
Tweet
with a message string?
- rails g model Tweet message
- What is the command to update your database with changes?
- rake db:migrate
- What is the purpose of migrations?
- to apply changes to the database schema
- 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
- What is the command to generate a controller called
tweets
?
- rails g controller tweets
- 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
- What is the default view templating engine in rails?
- erb
- What is the code to validate a tweet's message is reqired when making a new tweet?
- validates :message, presence: true
- What does
REST
stand for?
- representational state transfer
- 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.
- What folder can we use in our rails app to define custom rake tasks?
- lib/tasks
- In rails, the method
number_to_currency
is a what?
- helper
- In rails, when using a relational database, all models inherit from what class?
- ActiveRecord::Base
- What is the command to create a new migration file for adding location to a tweet?
- rails g migration add_location_to_tweet location
- 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
- In
SQL
, how would I query for the number of records in mytweets
table?
- select count(id) from tweets;
- In
rails
, how would I query for the number of records in myTweet
model?
- Tweet.count
- What is the command to start your rails application?
- rails server
- What port does your rails application run on by default locally?
- 3000
- Name 3 types of database associations:
- belongs_to, has_many, has_many_through
- What is
params
?
- refers to the parameters passed to application in a web request
- 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)
- Where would you write a custom helper method?
- app/helpers
- What is the
SQL
code for finding all tweets where the location is equal to "Salt Lake"?
- select * from tweets where location = 'Salt Lake';
- What is the
rails
code for finding all tweets where the location is equal to "Salt Lake"?
- Tweet.where(location: 'Salt Lake')
- 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)
- 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
- I have this route
tweet GET /tweets/:id(.:format) tweets#index
. What two helper methods can I use?
- link_to, button_to
- What does the parenthesis in a route denote?
- optional parameters
- What do the symbols in a route mean?
- parameters that are passed in during the request
- All pages use which HTTP verb?
- GET and/or HEAD
- Which helper method will create an html anchor tag for us?
- link_to
- Which helper method will create an html form tag for us?
- form_tag and form_for
- Which helper method will create an html password field for us?
- password_field
- The instance variable
@tweets
can most likely be used like what data type?
- array of objects
- What construct can we use in a view to write ruby code?
- embedded ruby, erb
- What is the code to iterate over a
@tweets
variable in a view?
- <% @tweets.each do |tweet| %>
- <%= tweet.do_stuff %>
- <% end %>
- What is the method to save a newly created record to the database in rails?
- save
- What is the method to remove a record from the database in rails?
- destroy
- What is the method to update some of the attributes of an object in rails?
- update
- Aside from a tweet, what other model could twitter possibly use?
- user
- What is the command to see all of the urls defined in my rails application?
- rake routes
- 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)
- Is your brain hurting yet?
- not really, but my arms are
- What is the current version of rails?
- 4.1.6
- When was rails created?
- July 2004
- Who created rails?
- David Heinemeier Hansson
- 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)
- What is a partial?
- sections of code to be shared across multiple views.
- How can you tell a file is a partial?
- filename is prefixed with an underscore
- PostgeSQL is what type of database?
- relational
- Name another database engine similar to PostgreSQL.
- MySQL
- Name a database engine that is a different type from PostgreSQL:
- NoSQL, Cassandra
- Are you ready for the last question?
- yes. this isn't interesting anymore
- What is a
foreign key
used for?
- linking associations across different tables within a database
- Did you really think question 67 was the last?
- no
- What method in the the routes file do I use to define my home page?
- root
- What does SASS stand for?
- Syntactically Awesome Style Sheets
- What is SASS used for?
- making CSS suck less
- What gem group would you put
pry-rails
into?
- development
- 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.