есть макрос, называемый «поведение», который может помочь (на примере bonyiii):
def generate_model
if behavior == :invoke
Rails::Generators.invoke("active_record:model", ["foo", "--no-migration"], behavior: behavior)
Rails::Generators.invoke("active_record:model", ["bar", "--no-migration"], behavior: behavior)
else # behavior == :revoke
Rails::Generators.invoke("active_record:model", ["foo", "--no-migration"], behavior: :revoke)
Rails::Generators.invoke("active_record:model", ["bar", "--no-migration"], behavior: :revoke)
end
end
или просто:
def generate_model
Rails::Generators.invoke("active_record:model", ["foo", "--no-migration"], behavior: behavior)
Rails::Generators.invoke("active_record:model", ["bar", "--no-migration"], behavior: behavior)
end