Rails updatedat not updating

25 Jan

Due to the nature of our application, contacts need to be queried by phone number, not only by id.

In this case, there might be the following line in the code .

In this case, we can cache our product index and specify a condition which invalidates the cache of products.

app/controllers/products_which is a shortcut for caching the product until its updated_at time changes. The more complex a database query is, the more it stands to gain from being cached.

We need to send the database a memo telling it to optimize itself to be able to look up contacts using their phone number. In Active Record, you do this with a migration: Now, when we look up a contact by its phone number, the database knows exactly where to look to locate that contact and can return it in a fraction of the time.

As your application grows and your models and their relationships become more and more complex, one of the biggest sink-holes for performance is the N 1 query.

Active Record’s cache can store queries in memory, taking a load off the database.

Since it’s easier and more cost effective to replicate your web server across many instances than it is to scale your database, caching can be a great performance booster. When a user visits your store, they request the Product#index route. Since you only update your product offerings occasionally, it’s unnecessary to hit the database every time a user comes to your site.

When I look at the response json, the image_id is null even though I set it to a specific value 6372517251 in my PUT json.

Furthermore the response json contains a field "image" on product level which is not in the documentation.