W7D3 Flashcards

1
Q

By default what do we get back from the database when we make a request for data in our Rails controllers?

A

By default, we get all attributes, which is bad because we will send everything to the client, including password digests.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does Jbuilder do?

A

Jbuilder constructs JSON views with curated data using Ruby.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In place of Rails views(.html.erb), what will we use?

A

We will Jbuilder templates with the extension of ‘.json.jbuilder’.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does Jbuilder template do?

A

Jbuilder templates are there to be compiled by the Rails and you’ll be left with a JSON template.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What do you want to do in the routes if you use JSON templates?

A

You want to set the default format of resources to :json, which will allow Rails to automatically look for .json file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the basic concepts of normalizing data?

A

Normalized state allows:

  1. Each type of data gets its own ‘table’ in the state.
  2. Each ‘data table’ should store the individual items in an object with the IDs of the items as keys and the items themselves as the values.
  3. Any references to individual items should be done by storing the item’s ID.
  4. Arrays of IDs should be used to indicate ordering.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the purpose of normalized state?

A

Normalized state is used to manage relational data or nested data in the Redux store by treating a portion of your store as a database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What’s going on in the code below?

const blogPosts = [
    {
        id : "post1",
        author : {username : "user1", name : "User 1"},
        body : "......",
        comments : [
            {
                id : "comment1",
                author : {username : "user2", name : "User 2"},
                comment : ".....",
            },
            {
                id : "comment2",
                author : {username : "user3", name : "User 3"},
                comment : ".....",
            }
        ]    
    },
    {
        id : "post2",
        author : {username : "user2", name : "User 2"},
        body : "......",
        comments : [
            {
                id : "comment3",
                author : {username : "user3", name : "User 3"},
                comment : ".....",
            },
            {
                id : "comment4",
                author : {username : "user1", name : "User 1"},
                comment : ".....",
            },
            {
                id : "comment5",
                author : {username : "user3", name : "User 3"},
                comment : ".....",
            }
        ]    
    }
    // and repeat many times
]
A

blogPosts is trying to access the entire database of posts, which will cause nesting. It is not using normalize state to treat a portion of the store as if it were a database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly