Skip to content

Instantly share code, notes, and snippets.

@pyk
Forked from schneems/gist:3079202
Last active August 29, 2015 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pyk/8815299 to your computer and use it in GitHub Desktop.
Save pyk/8815299 to your computer and use it in GitHub Desktop.
## Week 5 Quiz
## 0) Name 3 types of variables in Ruby? Put them in order from least scope to greatest.
local variable (var) , instance variable (@var), class variable (@@var), constant variable (VAR)
## 1) Where do SQL queries belong, the view or controller?
controller
## 2) Controllers are can do 4 types of operations what are they (RRFF)?
render, redirect, format, filter
## 3) List the routes it usually take to fully implement CRUD in a web app:
index
show
edit
create
update
new
destroy
## 4) What view typically holds a form that submits to the `create` action?
new.html.erb
## 5) What view typically holds a form that submits to the `update` action?
edit.html.erb
## 6) If you forget what routes are available, what command can you run from the command line to help remember?
$ rake routes
## 7) Below is part of a route.rb file that would be mapped to the appropriate controller, replace this with one line of code.
resources :comments
## 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
on specific course. so, show action will be executed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment