Code Monkey home page Code Monkey logo

Comments (11)

eLod avatar eLod commented on August 27, 2024

just to be clear/explicit: because Cloudtasker::WorkerController is not subclassing Cloudtasker::ApplicationController, the former is not having the skip_before_action :verify_authenticity_token (from the latter) leading to the ActionController::InvalidAuthenticityToken error

edit: also this only happens in development environment, eg in production because of eager loading the Cloudtasker::ApplicationController is loaded.

from cloudtasker.

alachaum avatar alachaum commented on August 27, 2024

@eLod thanks for raising this issue. It looks weird to me that Cloudtasker::WorkerController is not inheriting Cloudtasker::ApplicationController in your context. Could you provide a minimal example on a repo which mimics your setup? I'll do some checks on my side as well.

from cloudtasker.

eLod avatar eLod commented on August 27, 2024

well, i just checked, with a bare new rails app, only change is adding the cloudtasker gem:

with rails 5

% rails c
Running via Spring preloader in process 32560
Loading development environment (Rails 5.2.6)
irb(main):001:0> ApplicationController
=> ApplicationController
irb(main):002:0> Cloudtasker::WorkerController.ancestors.include?(Cloudtasker::ApplicationController)
=> false

with rails6

% rails c
Running via Spring preloader in process 32564
Loading development environment (Rails 6.0.4)
irb(main):001:0> ApplicationController
=> ApplicationController
irb(main):002:0> Cloudtasker::WorkerController.ancestors.include?(Cloudtasker::ApplicationController)
=> true

from cloudtasker.

eLod avatar eLod commented on August 27, 2024

upon further checking it seems our active admin & devise & devise_authy initialization process is causing the ApplicationController to be loaded and causing the problem. i still think it's worth it to fix it in this library, but the fix is trivial (and the problem does not seem to affect rails 6), plus i am not sure how much of legacy code in our application is causing the problem, so feel free to close this issue.

from cloudtasker.

eLod avatar eLod commented on August 27, 2024

well, its active_admin and devise, the routes include something like devise_for :users, ActiveAdmin::Devise.config, where ActiveAdmin::Devise refers to ::Devise::SessionsController which subclasses Devise.parent_controller.constantize through DeviseController, which in turn is simply ApplicationController.

i can confirm, with the bare new rails app, adding activeadmin and devise latest versions, and placing ActiveAdmin::Devise.config inside config/routes.rb

rails5

% rails c
Running via Spring preloader in process 36686
Loading development environment (Rails 5.2.6)
irb(main):001:0> Cloudtasker::WorkerController.ancestors.include?(Cloudtasker::ApplicationController)
=> false

rails6

% rails c
Running via Spring preloader in process 36962
Loading development environment (Rails 6.0.4)
irb(main):001:0> Cloudtasker::WorkerController.ancestors.include?(Cloudtasker::ApplicationController)
=> true

from cloudtasker.

eLod avatar eLod commented on August 27, 2024

oh i just found, most likely this somewhat cryptic pr #36 is trying to solve the same issue

from cloudtasker.

alachaum avatar alachaum commented on August 27, 2024

Going to do more testing on my side. Looks like PR #36 is the way to go in the end.

from cloudtasker.

eLod avatar eLod commented on August 27, 2024

i really feel #36 is the wrong "solution", it keeps subclassing ::ApplicationController (while Cloudtasker::ApplicationController becomes unused) which can introduce other problems in turn. i would suggest to simply correct the namespacing (or drop rails 5.2 support, or somehow note the problem, like in readme).

from cloudtasker.

alachaum avatar alachaum commented on August 27, 2024

I'll rewrite this PR. We can just get rid of ApplicationController I suppose - it's fairly useless.

from cloudtasker.

eLod avatar eLod commented on August 27, 2024

sure that is also a solution, most likely the best one

from cloudtasker.

alachaum avatar alachaum commented on August 27, 2024

This issue has been fixed in the following releases:

  • v0.9.5
  • v0.10.2
  • v0.11.1
  • v0.12.1

from cloudtasker.

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.