Skip to content

Instantly share code, notes, and snippets.

@schneems
Created July 9, 2012 21:45
Show Gist options
  • Save schneems/3079202 to your computer and use it in GitHub Desktop.
Save schneems/3079202 to your computer and use it in GitHub Desktop.
Week 5 Quiz
## Week 5 Quiz
## 0) Name 3 types of variables in Ruby? Put them in order from least scope to greatest.
## 1) Where do SQL queries belong, the view or controller?
## 2) Controllers are can do 4 types of operations what are they (RRFF)?
## 3) List the routes it usually take to fully implement CRUD in a web app:
## 4) What view typically holds a form that submits to the `create` action?
## 5) What view typically holds a form that submits to the `update` action?
## 6) If you forget what routes are available, what command can you run from the command line to help remember?
$ ____________
## 7) Below is part of a route.rb file that would be mapped to the appropriate controller, replace this with one line of code.
get '/comments'
get '/comments/new'
get '/comments/:id/edit'
get '/comments/:id'
post '/comments'
delete '/comments/:id’
put '/comments/:id'
## 8) Below is the code for a controller and a view, what controller action will be hit when you click on a link labeled "click me"?
app/controllers/courses_controller.rb
def index
@courses = Course.all
end
app/views/courses/index.html.erb
<h2>Courses</h2>
@courses.each do |course|
<%= link_to "click me", course %>
end
@javogc
Copy link

javogc commented Dec 18, 2014

  1. local, instance and class variables
  2. they belong to the controllers
  3. C(creat), R(read),U(update,D(destroy)
  4. #index
  5. new.html.erb
  6. edit.html.erb
  7. rake routes
  8. resource :comments
  9. The index

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