graphiti-api / graphiti-rails

MIT License
54 stars 28 forks source link

ResourceGenerator overwrites existing controller #35

Open LoganDSPrice opened 4 years ago

LoganDSPrice commented 4 years ago

Overwriting existing controllers when generating a resource limits the utility of the gem. It makes it much more difficult to add Graphiti to an existing application.

Pain point Adding Graphiti to an existing application with generate graphiti:resource [RESOURCE_NAME] --model=[MODEL_NAME] overwrites the existing controller. You can skip the overwrite, but then the controller code must be written by hand. Also, if you use destroy graphiti:resource... it deletes the controller file whether the generator initially overwrote the file or not. This inflexibility also increases the difficulty of calling the generator inside other custom generators.

Suggested solutions:

arjan0307 commented 4 years ago

I''m dealing with the same problem. The workaround I use is overwrite the controller, move the controller to the namespace and then use git checkout to restore the original controller, which is far from ideal.