Skip to content

Instantly share code, notes, and snippets.

@Rubiromi
Created June 17, 2014 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rubiromi/8e4aa44d931555240a32 to your computer and use it in GitHub Desktop.
Save Rubiromi/8e4aa44d931555240a32 to your computer and use it in GitHub Desktop.
1. What does MVC stand for?
Minimal Valuable Product
2. What is the purpose of MVC?
To release a first version of the product with enough stuff to cover minimal features, and it still covers a purpose of the product.
3. What is the command you would use to generate a new rails application called "twitter"?
rails new twitter
4. Which file do you edit to add additional gems to your rails app?
gemfile
5. What is the purpose of .gitignore file?
Not to upload the files you don't want Git to check in to GitHub.
6. What is the app/assets folder used for?
7. What is the vendor/assets folder used for?
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?
Pathname
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 generate Tweet message:string
14. What is the command to update your database with changes?
rake db:migrate
15. What is the purpose of migrations?
...to update your database
16. What is the job of the controller?
The controller is responsible for making sense of the request and producing the appropriate output.
17. What is the command to generate a controller called tweets?
rails generate controller tweets
18. Define a route for showing all the tweets in our controller and a route for showing a specific tweet:
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 :message, presence: true
21.What does REST stand for?
22. What is the purpose of rake?
Rake uses Ruby's anonymous function blocks to define various tasks, allowing the use of Ruby syntax.
23. What folder can we use in our rails app to define custom rake tasks?
db folder
24. In rails, the method number_to_currency is a what?
It converts inputted integer to currency (i.e. $5.00).
25. In rails, when using a relational database, all models inherit from what class?
Parent class
26. What is the command to create a new migration file for adding location to a tweet?
rails generate migration AddsLocationToTweets 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?
select count(*) from tweets
29. In rails, how would I query for the number of records in my Tweet model?
Tweet.count
30. What is the command to start your rails application?
rails server
31. What port does your rails application run on by default locally?
localhost:3000
So, port is 3000
32. Name 3 types of database associations:
1 to 1
1 to many
many to many
33. What is params?
The params come from the user's browser when they request the page, or the form data of a post request. It also come from the path of the URL.
34. What is flash?
The flash provides a way to pass temporary objects between actions. It's a good way of doing notices and alerts.
35. Where would you write a custom helper method?
models_helpers.rb
36. What is the SQL code for finding all tweets where the location is equal to "Salt Lake"?
select * from tweets where lower(name) like 'salt lake%';
37. What is the rails code for finding all tweets where the location is equal to "Salt Lake"?
Tweet.where("lower(location)like ?", "#{salt lake}%")
38. What is the rails code for finding only a max of 5 tweets where the location begins with "Salt Lake"?
Tweet.where("lower(location)like ?", "#{salt lake}%").(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?
before_action
40. I have this route tweet GET /tweets/:id(.:format) tweets#index. What two helper methods can I use?
tweet_path(:id) and ...
41. What does the parenthesis in a route denote?
It's optional parameter
42. What do the symbols in a route mean?
The # is used to denote that you are choosing the action (method) index from the controller (class) store.
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_for
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?
string
48. What construct can we use in a view to write ruby code?
erb tag
49. What is the code to iterate over a @tweets variable in a view?
<% @tweets.each do |tweet| %>
<% tweet.record %>
<% end %>
50. What is the method to save a newly created record to the database in rails?
n = Record.new
n.save
51. What is the method to remove a record from the database in rails?
52. What is the method to update some of the attributes of an object in rails?
validates + attributes
53. Aside from a tweet, what other model could twitter possibly use?
Member
54. What is the command to see all of the urls defined in my rails application?
rake routes
55. What file do I use to update the styles for my application?
css.scss files in stylesheets folder
56. Is your brain hurting yet?
It's been hurting since last week.
57. What is the current version of rails?
4.0.2
58. When was rails created?
first released in July 2004
59. Who created rails?
David Heinemeier Hansson
60. What is the purpose of scaffolding?
It's a rapid prototyping tool.
61. What is a partial?
It's a method for rendering sub templates within the current controller that depends on a single object.
62. How can you tell a file is a partial?
63. PostgeSQL is what type of database?
object relational database
64. Name another database engine similar to PostgreSQL.
MySQL, Oracle, DB2
65. Name a database engine that is a different type from PostgreSQL:
MongoDB, Cassandra, HBase
66. Are you ready for the last question?
I was ready at question number 3.
67. What is a foreign key used for?
To define which table belong to the other one.
i.e. which one is the parent and which one is the child.
68. Did you really think question 67 was the last?
No, because I skipped a lot and started back from number 73. :)
69. What method in the the routes file do I use to define my home page?
root 'home#index'
70. What does SASS stand for?
Syntactically Awesome StyleSheets
71. What is SASS used for?
HTML templates. It's a sort of shorthand way to writing css that can really help clean up complex style sheets.
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 controller called about with about.html.erb file.
* create a link in application.html.erb, so I can go to about page through global navigation.
* type contents in about.html.erb file.
* update about_contoroller.rb to match with html pages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment