After updating ruby-3.2.2 and using pundit-2.1 version, Getting error: Invalid constructor<> is called #777
-
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
I tried, but I can't find a way to reproduce your error. You need to provide some more information. A detailed backtrace would provide more clues, since the Absolute best would be if you could provide a small example we can run ourselves that shows your error. From the context you've provided, I'm thinking:
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I'm sorry, I don't think I can help you with that information. I would advise you to figure out why the The Pundit source code is relatively small. There's not a lot to dig through. I tried to replicate the code you sent in a full example, but it runs just fine with no errors. It took too long trying to figure out how to bootstrap Rails in this tiny example. require "bundler/inline"
gemfile do
source "https://rubygems.org"
ruby "3.2.2"
gem "pundit", "2.1.0"
end
class ApplicationController
include Pundit
def current_user = "Not actual User"
end
class HomeController < ApplicationController
def index
authorize :home
"Works fine!"
end
private
# Rails sets this. Pundit uses it to find the query method.
def action_name = :index
end
class ApplicationPolicy
def initialize(user, record)
@user = user
@record = record
end
end
class HomePolicy < ApplicationPolicy
def index? = true
end
controller = HomeController.new
puts controller.index # => "Works fine!" |
Beta Was this translation helpful? Give feedback.
-
Its a misleading error. Problem was in delegation method in ruby 3.0. Thanks for your support. Appreciate for that! |
Beta Was this translation helpful? Give feedback.
Its a misleading error. Problem was in delegation method in ruby 3.0. Thanks for your support. Appreciate for that!