Hyrax: Allow for work types to be in a namespace

Created on 19 Jan 2017  路  5Comments  路  Source: samvera/hyrax

For a work type like a book, can we allow for namespaces so that different kinds of books can be created in apps. At this point, I believe, the work must live in app/models/concerns/book. It would be nice if they could live in app/models/my_plugin/book or in a gem in [path_to_my_plugin]/app/models/my_plugin/book.rb

Most helpful comment

I suggest we write the ticket in this way:

As a developer
when I run $ rails g hyrax:work my_plugin/book I should see
the model, controller, actor, form and locales generated with the my_plugin namespace and they should be in a my_plugin subdirectory.
additionally the line config.register_curation_concern ... generated in config/initializers/hyrax.rb should define a namespace.
The generated routes should have the namespace in their path.

The current behavior is that it adds the namespace to the generated files, but puts them in the wrong (root) directory. The routes are not namespaced. The translations are not namespaced.

All 5 comments

Thoughts on the above, @projecthydra-labs/hyrax-code-reviewers?

@cam156 you could do this, but this would require a data migration as ActiveFedora stores the class name as an assertion on the fedora object.

@jcoyne I should have said optional namespace.
I was thinking the the command would work as normal in this instance

rails g hyrax:work book

But in this instance it would create the directory.

rails g hyrax:work my_plugin::book

By playing with the command it seems to just create the book model named incorrectly currently.

I suggest we write the ticket in this way:

As a developer
when I run $ rails g hyrax:work my_plugin/book I should see
the model, controller, actor, form and locales generated with the my_plugin namespace and they should be in a my_plugin subdirectory.
additionally the line config.register_curation_concern ... generated in config/initializers/hyrax.rb should define a namespace.
The generated routes should have the namespace in their path.

The current behavior is that it adds the namespace to the generated files, but puts them in the wrong (root) directory. The routes are not namespaced. The translations are not namespaced.

Note: this needs to avoid conflicting with the optional field:type arguments that are part of the signature for that generator:

rails generate hyrax:work NAME [field:type field:type]
Was this page helpful?
0 / 5 - 0 ratings