Gugubaight Gugubaight - 1 month ago 18
Ruby Question

Rails 4: NameError uninitialized constant ActionView::CompiledTemplates::Icons

I've stored an array in

config/initializers/icons.rb
:

class Icons
def self.emoticons
emoticons = ['( o_o )', 'ʕ•ᴥ•ʔ']
end
end


I assumed that I'd be able to access it with the following code from anywhere:

%p= Icons::emoticons.sample


or

%p= Icons.emoticons.sample


If I do that I get this error:

NameError in Tools#search
uninitialized constant ActionView::CompiledTemplates::Icons


What is wrong with my approach?

Answer

You were very close: Icons.emoticons.sample