ruby on rails - Unable to access model data from action -
i have controller:
class api::v1::account::sharingcontroller < applicationcontroller def show sharings = account::sharing.all render json: sharings, status: :ok end end the model:
path: models/account/sharing.rb class account::sharing < activerecord::base end route:
scope '/account' resource :sharing, controller: 'account.sharing', path: 'sharings' end i error: uninitialized constant api::v1::account::sharingcontroller::account, because of sharings = account::sharing.all
in rails console, able use , data with: account::sharing.all
why happening?
update
changes folder accounts , sharingcontroller sits in accounts/sharing_controller.rb , working.
the problem in controller searches account::sharing in controller's namespace. try prefixing :: tell search 'root' namespace so:
::account::sharing.all
Comments
Post a Comment