SELECT COUNT(id) FROM users;
returns 50
SELECT title, price FROM items ORDER BY price DESC LIMIT 5;
returns the following items:
The weekend assignment will not be a group project, but today will continue from where you left off yesterday.
Pair up and share a computer, switching off at the keyboard after each commit. Talk through your thought process with your pair and ...
Write API wrappers to:
1.1. What is the result of the ages.map call? What about ages.each? | |
The result of ages.map [28, 32, 42, 64] is [56, 64, 84, 128] | |
The result of ages.each is: | |
Age is: 28 | |
Age is: 32 | |
Age is: 42 | |
Age is: 64 | |
1.2. Is x in scope during ages.each? x is not in scope. |
1.1. The Student table has a one-to-many relationship with the Assignments table. One student to many assignments. | |
2.1 Four parts of a request: URL, Head, Body, and ?? | |
Three parts of a response: Status code, Head, Body | |
2.2. Query string is generally used for just retrieving data -- i.e., executing a query, where the response is the result of the query. The query string can be passed in the url. For example: http://apistuff.com/doit?q=string&abc=123 | |
Post data is generally used for sending data and receiving a response, where the response may be the updated data or a confirmation that the data was received. POST data cannot be passed in the url. | |
2.3. A POST request is usually the equivalent to Create, and a PATCH request is usually the equivalent to Update. |
1.1. Presumably it would delete the first post by the comment author. A user would need to have a has_many :posts relationship. | |
1.2. It would create a new comment in a post titled "New Years Resolution." It tells us that Post has a has_many relationship to comments. | |
2.1. One is with a query string, and the other is with a body. | |
2.2. Through the browser, at the end of a URL. | |
3.1. Less specific <== HTML element, Class, ID ==> More specific |
1.1. rake routes | |
1.2. Add the as: parameter | |
1.3. Run rake routes | |
2.1. Creating an object with an API may involve using any one or more of several types of requests. Creating an object with a website involves using a GET request. | |
2.2. <form> and <input type="submit">. Rails equivalents: form_tag and submit_tag. |
<?php | |
// Return an array of course offerings belonging to a category ID | |
// If it's a multi-week course, it should be set up as a recurring event | |
// This is a function used in several other areas of the code to simplify | |
// the process of grabbing event data for C4's class offerings. | |
function c4_event_array( $catid, $recur = true, $limit = 99 ) { | |
// First, grab the data based on the criteria given | |
$post_type = ( true == $recur ? 'event-recurring' : 'event' ); | |
$events = new WP_Query( | |
array( |
<?php | |
// Add course times for the Ignite enrollment form. | |
// Note: Some data is removed for security purposes. | |
add_filter('gform_pre_render_#', 'c4a_pre_render_#' ); | |
add_filter('gform_admin_pre_render_#', 'c4a_pre_render_#'); | |
function c4a_pre_render_# ($form) { | |
foreach($form['fields'] as &$field ) { | |
// If this is the "Ignite Time" radio button field in the form... | |
if( $field['adminLabel'] != 'Ignite Time' ) { continue; } | |
// ... remove the existing items so we can start with a new list. |
# Given several models with string or text fields | |
# where data entered those fields often contain | |
# leading or trailing spaces, find those fields. | |
Rails.application.eager_load! | |
problematic = {} | |
ApplicationRecord.descendants.each do |model| | |
model_key = model.to_s.downcase.to_sym | |
problematic.merge!({ model_key => [] }) | |
model.attribute_names.each do |attribute| |