• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/12

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

12 Cards in this Set

  • Front
  • Back

What is a hash?

A hash is a data structure comprised of key:value pairs, where values can be accessed by their respective key.

What is an array?

An array is a data structure comprised of a list of data (types including strings, numbers, arrays, or hashes) that can be accessed by their index.

What is a string?

A string is a data type that is a sequence of characters, enclosed by single or double quotes.

Explain REST.

REST is an acronym for Representation State Transfer. It's about using the HTTP Verbs GET, POST, PATCH/PUT, and DELETE to act on resources.

What is a URL?

A URL is a Uniform Resource Locator (also known as a web address). It is a reference to a web resource that specifies its location and a mechanism for retrieving it. A URL is a type of URI. EG: https://mattcassara.com/profile-pic.png

What is a URI?

A URI is a Uniform Resource Identifier. It is a compact sequence of characters that identifies a physical or abstract resource. It can mean name, location, or both.

What are the 4 RESTFUL verbs?

GET, POST, PUT/PATCH, DELETE. Although technically only GET and POST are supported by browsers.

For Ruby on Rails, what are the Seven Restful Routes?

1) Index (GET)


2) New (GET)


3) Create (POST)


4) Show (GET)


5) Edit (GET)


6) Update (PATCH)


7) Delete (DELET)

Explain Ruby's to_json method.

The to_json method serializes a Ruby object (converts it into a JSON data structure). Additional parameters can be passed with to_json, including which attributes to include/exclude, as well as object associations.

Explain Ruby's respond_to method.

Ruby's respond_to method returns a particular file type based on the requested file type. If i browse to www.website.com/posts/1, I'll likely be returned an HTML document. If the program uses respond_to and I browse to /posts/1.json, I'll be returned a JSON data structure.

Explain how to use Ruby's Active Model Serializer gem.

Active Model Serializer replaces a lot of the tedious work of serializing Ruby objects and rendering them when requested with a convention based approach. AMS is easy to use:


1) add the gem to your gem file and bundle


2) run 'rails g serializer [model name] to generate a serialization file


3) add the attributes you want to serialize including associations (this requires separate serialization files)


4) add a respond_to method in your controller to render HTML and JSON as necessary


5) add JS functions to the asset pipeline and API calls in your views as necessary

Explain how, generally, to submit an AJAX Post request through Ruby on Rails.

Assuming RESTFUL routes have already been configured and you have a working application that responds to regular requests...


1) In the asset pipeline, create a new JS function that will initiate the AJAX process a form is submitted.


1) Prevent it from reloading the page on submit (achieved with an event.preventDefault(); JS function)


2) Set the post URL to the appropriate resource route


3) Include the serialized data you are posting to the application


4) Include functions for handling Success and Error callbacks


5) on the resources create controller action, use respond_to to render JSON - this will be in the AJAX response. and remove any redirects!