我无法在我编写的渲染器类上调用任何方法。它的方法不应该暴露吗?
class EntriesController < ApplicationController
def show
BaseRenderer.renderer_for(@entry) # @entry is loaded with a before_filter
end
end
# app/renderers/base_renderer.rb
class BaseRenderer
def renderer_for(entry)
klass ||= "#{entry.entry_type}Renderer".constantize
klass.new(entry)
end
end
我明白了NoMethodError at ... undefined method 'renderer_for' for BaseRenderer:Class
但是方法是明确定义的。是什么赋予了?