1

我試圖讓我的頁面控制器的「顯示」動作渲染液體模板而不是普通視圖。模板本身存儲在數據庫中。在控制器中渲染液體模板

這是我的表演動作:

def show 
    @organization = Organization.find_by_subdomain(request.subdomain) 
    @template = Liquid::Template.parse(Template.find(@organization.current_template)) 
    @page = @organization.pages.find(params[:id]) 

    respond_to do |format| 
     format.html { render @template.render('page' => @page)} 
     format.json { render json: @page } 
    end 
    end 

但是,它會引發此異常:

uninitialized constant PagesController::Liquid 

我是一個RoR新手,我假設發生的事情是,它的嘗試在PagesController類中找到Liquid類,而不是意識到它本身就是一個類。我儘可能地遵循(有些稀疏的)指令here

我在做什麼錯?

回答

2

您需要包括液體在你的Gemfile中:

gem "liquid" 

然後運行bundle install並重新啓動服務器的軌道。

+1

啊,忘了重啓我的服務器!謝謝! – Asherlc 2012-07-29 20:51:48