How to convert module class name to symbol in rails

rails-engines, ruby, ruby-on-rails

Solution

You can control camel cases and namespaces in classification of strings by adding underscores or forward slashes to your config.objects.

Forward slashes classify to a namespace:

:"blogit/post".classify #=> Blogit::Post

Underscores classify to a camelcase:

:blogit_post.classify #=> BlogitPost

So in your case, the solution would be:

config.objects += [ :room, :hotel, :"blogit/post", ..etc ]

Or, if you use ruby 2.0, you can use a much cleaner way of array symbol instantiation:

config.objects += %i(room hotel blogit/post)

Problem

In a rails initializer file, there is a line for configuring activity objects that accepts symbols like so: ``` config.objects += [ :room, :hotel, ..etc ] ``` These symbols represent classes that I want configured. My problem is that i'm using a rails engine which defines a 'Blogit::Post' module class which I want to configure. How do I add this to the config array as a symbol?

Original source