hashrocket / decent_exposure

A helper for creating declarative interfaces in controllers
MIT License
1.81k stars 107 forks source link

ActionController::RoutingError at /api/v1/contacts: undefined method `helper_method' #171

Closed Quintasan closed 7 years ago

Quintasan commented 7 years ago

api_controller.rb

module Api::V1
  class ApiController < ActionController::API
    include DeviseTokenAuth::Concerns::SetUserByToken
    rescue_from ActiveRecord::RecordNotFound, with: :record_not_found

    def record_not_found
      render json: { errors: "Requested object not found" }, status: :not_found
    end
  end
end

contacts_controller.rb

module Api::V1
  class ContactsController < ApiController
    before_action :authenticate_user!
    expose(:contacts) { Contact.all }
    expose(:contact)
    def index; end
  end
end

Doing GET http://localhost:3000/api/v1/contacts yields ActionController::RoutingError - undefined method 'helper_method'

Full backtrace

What am I doing wrong?

mattpolito commented 7 years ago

@Quintasan Is this no longer an issue or did it end up being something outside of decent_exposure?