This tutorial assumes that you generated a work type name GenericWork. If you used a different name, substitute that name for all occurrences of GenericWork and generic_work.
Creating controlled vocabularies is not required for your app, but we will be using one in this tutorial. So we’ll go ahead and create it now.
Controlled vocabularies can be created in your app and then accessed through the Questioning Authority (QA) gem. These instructions show a simple way to create your own controlled vocabulary. To get information on accessing external authorities and details on creating local sub-autorities, see the QA README, especially the Local Sub-Authorities section.
Authorities are defined as a yml file in config/authorities. Here we will define a departments controlled vocabulary.
- id: eng
- id: hst
- id: ltn
- id: zoo
Create a service to load the vocabulary
A service is required to set up Questioning Authority to return all the values, which will be used to populate the selection list, and a single value given an id, which will be used to show the value instead of the id on the show page.
self.authority = Qa::Authorities::Local.subauthority_for('departments')
authority.all.map do |element|