Giter Site home page Giter Site logo

Comments (3)

jodosha avatar jodosha commented on May 17, 2024

@baob Hey thanks for reporting this. Are you using lotus-controller as standalone component or inside a Lotus app?

Actions are mutable, in order to make your application safe you must use a new instance for each request. This is handled for you by lotusrb, but not if you use lotus-controller alone.

Please let me know.

from controller.

baob avatar baob commented on May 17, 2024

We are using the two gems (Controller and Router) standalone, we are not using the full lotus app. Can you point me in the right direction please ? I read something yesterday about mutable actions, but what I read suggested that Router would create a new instance every time, so I thought it would not apply to our situation.

This is our routing code:

          Lotus::Router.new do
            get '/subjects/:subject_slug',       to: Actions::SubjectsShow
          end

Is it just a case of adding .new to the class referenced ? Or is there another prefered way to do it ? E.g. I've seen references to using Lotus::Controller.load! but I have no idea where to place that code.

from controller.

jodosha avatar jodosha commented on May 17, 2024

@baob

You have two solutions:

  • You can add a class method for each action .call and do:
def self.call(env)
  new.call(env)
end

See more at: https://github.com/lotus/controller#thread-safety

  • Or you can on action naming syntax (to: 'actions#subjects_show)

from controller.

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.