I am getting this error when i am trying to authorize through pundit and authenticate through Devise.
ArgumentError - wrong number of arguments (1 for 0):
pundit (1.1.0) lib/pundit.rb:194:in `authorize'
app/controllers/trips_controller.rb:23:in `new'
actionpack (4.2.5) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.2.5) lib/abstract_controller/base.rb:198:in `process_action'
My application_controller.rb is
class ApplicationController < ActionController::Base
include Pundit
protect_from_forgery with: :exception
rescue_from Pundit::NotAuthorizedError, with: :permission_denied
....
end
Have a application_policy.rb as follows
class ApplicationPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def index?
false
end
def show?
scope.where(:id => record.id).exists?
end
def create?
false
end
def new?
create?
end
def update?
false
end
def edit?
update?
end
def destroy?
false
end
def scope
Pundit.policy_scope!(user, record.class)
end
class Scope
attr_reader :user, :scope
def initialize(user, scope)
@user = user
@scope = scope
end
def resolve
scope
end
end
end
My trip_policy.rb
class TripPolicy < ApplicationPolicy
def new?
user.provider?
end
def create?
user.provider?
end
def update?
user.provider?
end
end
And in my trips_controller i am doing this
class TripsController < ApplicationController
before_action :authenticate_user!
after_action :verify_authorized, except: [:index, :new]
...
def new
@trip = Trip.new
authorize @trip
end
...
end
Any pointer why am i getting this error. Have been breaking my head for some time now.