【发布时间】:2012-07-29 21:26:25
【问题描述】:
我正在尝试渲染存储在数据库中的液体模板。
这是我在控制器中的“显示”操作:
def show
@organization = Organization.find_by_subdomain(request.subdomain)
@template = Liquid::Template.parse(Template.find(@organization.current_template).body)
@page = @organization.pages.find(params[:id])
respond_to do |format|
format.html { render @template.render('page' => @page), :template => false}
format.json { render json: @page }
end
end
但是,当我访问该页面时,我得到一个“模板缺失”异常并出现以下错误(注意“测试测试”是页面对象的主体属性,这是当前唯一在模板):
Missing template /testing testing with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee, :haml]}.
Searched in: * "/Users/ashercohen/Documents/Rails/Vocalem-Rails/app/views"
* "/Users/ashercohen/.rvm/gems/ruby-1.9.3-p194/gems/twitter-bootstrap-rails-2.1.1/app/views"
* "/Users/ashercohen/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/app/views"
当我专门传递了:template => false 参数时,它为什么要尝试查找另一个模板?我在这里缺少什么吗?我正在尝试绕过使用任何模板文件,因为这里似乎不需要它们(尽管如果我错了我不会强烈反对)。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.2 template-engine liquid