Alternatively, you can include the module in every model class file to equip the CMS objects based on one of these classes with the language attribute. In our case, these classes are "app/models/homepage.rb", "app/models/image.rb", and "app/models/page.rb."
For CMS objects that have a path, the code above automatically sets their language to the language of the corresponding homepage on creation. However, some CMS objects such as images or PDF files are not meant to be part of the visible website structure and therefore don't have a path. For those objects, the language attribute needs to be set by other means. A simple solution is to enable editors to set the language of images by extending the details view so that the
language attribute becomes editable. For this, add the following piece of code at the end of the details template for images: