Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rabl nested object caching #418

Open
amalhotra opened this issue Mar 7, 2013 · 2 comments
Open

Rabl nested object caching #418

amalhotra opened this issue Mar 7, 2013 · 2 comments

Comments

@amalhotra
Copy link

http://stackoverflow.com/questions/15277146/rabl-caching-with-nested-object

I can repost if needed. I also tried

cache root_object # instead of cache @Retailer

in _school.json.rabl

@amalhotra
Copy link
Author

I added my current solution to stackoverflow above (splitting the view). Another issue is caching the partial itself. How do I cache within the partial?

@panupan
Copy link

panupan commented Apr 9, 2013

I don't think this is a Rabl bug. Looks more like a design issue with how your templates are setup. If Students belong to a School, Students should be nested under the School template. If you are looking at individual students, you should pull the Schools in a separate request and refer to them using their foreign keys. If you really need to render the entire school template under each student, you'll need to figure out how to implement reverse touch or disable caching.

Your data should look something like this:

{
  school: {
    id: 1,
    name: "Stanford",
    students: [
      {
         id: 1000,
         name: "John Doe",
         school_id: 1
      },
      {
         id: 1001,
         name: "Jane Doe",
         school_id: 1
      } 
    ]
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants