I have the following statement which does work although it uses eval:
def resource_name
self.class.to_s.match(/(.+)Controller/)[1].singularize
end
def collection
@collection ||= eval "#{resource_name}.all(sort: [[:name, :asc]])"
end
Is there a better way of doing this that does not use eval?