Asherlc
Asherlc

Reputation: 1161

Rendering Liquid Template in Controller

I'm trying to have the "show" action for my pages controller render a Liquid template instead of the normal view. The template itself is stored in the database.

This is my show action:

  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

However, it raises this exception:

uninitialized constant PagesController::Liquid

I'm a RoR newbie, so I'm assuming what's happening is that it's trying to find the Liquid class in the PagesController class, instead of realizing it's a class unto itself. I'm following the (somewhat sparse) instructions here as best I can.

What am I doing wrong?

Upvotes: 2

Views: 1822

Answers (1)

iblue
iblue

Reputation: 30424

You need to include liquid in your Gemfile:

gem "liquid"

Then run bundle install and restart your rails server.

Upvotes: 2

Related Questions