Giter VIP home page Giter VIP logo

Comments (7)

dhh avatar dhh commented on June 9, 2024

@rolftimmermans, can you look at the blankslate issue?

@rgarver, can you check the caching problem?

from jbuilder.

rgarver avatar rgarver commented on June 9, 2024

I can replicate this result. Not sure why the tests aren't catching this.

from jbuilder.

rgarver avatar rgarver commented on June 9, 2024

Ah, @fluxsaas in order for this to work you need to pass in a context for the cache! call. Eg:

  # index.json.jbuilder
  json.cache! "users" do |json|
    json.users @users do |json, user|
      json.id user.id
    end
  end

The reason it was failing for you is because you were attaching the users to the json context outside the cache! scope. Try this and let me know how it works.

from jbuilder.

dhh avatar dhh commented on June 9, 2024

Oh, doh. I missed that part too.

from jbuilder.

rolftimmermans avatar rolftimmermans commented on June 9, 2024

Although I agree that an explicit argument to the block is how the current API works, I think it might worth considering supporting the other variant too. Currently the json block arguments are always redundant and only there for backwards API compatibility. You'll always get the same instance of Jbuilder.

To me it makes sense to implement cache! in the same new way. It is simpler, faster and leads to fewer bugs. For example, cache! currently resets the key formatter, which is not what may be expected. I can try to write a patch later.

from jbuilder.

dhh avatar dhh commented on June 9, 2024

Do look into the complications of not requiring the yield. We definitely still want to use the json yield at the top-level to tie all calls off, but maybe we don't need it in the subsequent blocks.

On Sep 25, 2012, at 10:32 AM, Rolf Timmermans wrote:

Although I agree that an explicit argument to the block is how the current API works, I think it might worth considering supporting the other variant too. Currently the json block arguments are always redundant and only there for backwards API compatibility. It would make sense to implement cache! in the same new way. It is simpler and leads to fewer bugs. For example, cache! currently resets the key formatting to default, which is not what may be expected. I can try to write a patch later.


Reply to this email directly or view it on GitHub.

David Heinemeier Hansson

from jbuilder.

fluxsaas avatar fluxsaas commented on June 9, 2024

yes, works fine. i guess i was used to the rails cache method and missed the scope...

from jbuilder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.