You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. 👋 When using ROM commands within a slice, they end up as nil objects. My initial guess is something is broken with object inheritance because commands work if used with repository objects within the application slice (i.e. the main slice).
How
In my case, I have a Tasks slice which uses ROM commands for create, update, and delete:
Source Code
# frozen_string_literal: truemoduleTasksmoduleRepositories# Defines the tasks repository.classTask < DB::RepositoryORDER=proc{created_at.asc}# TODO: Enable once Hanami 2.2.0 supports commands.# commands :create, update: :by_pk, delete: :by_pkdefinitialize(order: ORDER, **)@order=ordersuper(**)enddeffind(id)=tasks.combine(:user).by_pk(id).onedeffind_by_descriptiontexttasks.combine(:user).where{description.ilike"%#{text}%"}.to_aenddefall=tasks.combine(:user).order(&order).to_a# TODO: Remove once Hanami 2.2.0 supports commands.defcreate(attributes)=tasks.changeset(:create,attributes).commit# TODO: Remove once Hanami 2.2.0 supports commands.defupdate(id, **)=tasks.by_pk(id).update(**)# TODO: Remove once Hanami 2.2.0 supports commands.defdelete(id, **)=tasks.by_pk(id).delete(**)privateattr_reader:orderendendend
Notice that I've disabled (commented) the commands macro in favor of creating the equivalent methods for create, update, and delete. That's the workaround. ...but I'd prefer to use only the commands macro and delete the additional methods.
This appears to work when working within a normal Hanami 2.2.0, Beta 2 application with no slices.
Why
Hello. 👋 When using ROM commands within a slice, they end up as
nil
objects. My initial guess is something is broken with object inheritance because commands work if used with repository objects within the application slice (i.e. the main slice).How
In my case, I have a
Tasks
slice which uses ROM commands for create, update, and delete:Source Code
Notice that I've disabled (commented) the
commands
macro in favor of creating the equivalent methods for create, update, and delete. That's the workaround. ...but I'd prefer to use only thecommands
macro and delete the additional methods.This appears to work when working within a normal Hanami 2.2.0, Beta 2 application with no slices.
Steps to Recreate
220
branch of my Hemo application.bin/setup
.commands
macro and comment thecreate
,update
, anddelete
methods.nil
exceptions being thrown. You can revert the changes to make the specs pass again.The text was updated successfully, but these errors were encountered: