From afc15db53cda0230cba392edea1f74d8f57be253 Mon Sep 17 00:00:00 2001 From: RichMorin Date: Thu, 12 Aug 2010 13:45:58 -0700 Subject: [PATCH] Migrated from using-liquid-without-rails v4 --- Using-Liquid-without-Rails.textile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Using-Liquid-without-Rails.textile b/Using-Liquid-without-Rails.textile index 02119eb..54884bf 100644 --- a/Using-Liquid-without-Rails.textile +++ b/Using-Liquid-without-Rails.textile @@ -1,4 +1,5 @@ -Want to use Liquid along with some plain old Ruby code? The secret is creating a to_liquid method on any classes you create. +Want to use Liquid along with some plain old Ruby code? +The secret is creating a @to_liquid@ method on any classes you create. Let's say you have a Product class: @@ -25,7 +26,12 @@ You excitedly execute your code expecting to see your beautiful new sentence, bu
I'm running to the store with Liquid error: undefined method `to_liquid' for #
-to_liquid? Where did that come from? Turns out you need to add a method to your class that returns your instance variables as part of a hash. (Liquid was built to be very paranoid about not letting people access something they're not supposed to, so you need to explicitly let liquid know how to access everything in your object.) So we update the Product class description to include that method: +@to_liquid?@ +Where did that come from? +Turns out you need to add a method to your class that returns your instance variables as part of a hash. +(Liquid was built to be very paranoid about not letting people access something they're not supposed to, +so you need to explicitly let Liquid know how to access everything in your object.) +So, we update the @Product@ class description to include that method:
class Product
   attr_accessor :name, :price