From b4f30bad5680b18b97080b91ec2345fab4295db7 Mon Sep 17 00:00:00 2001
From: cannikin
+sentence = "I'm running to the store with {{ product.price }} dollars in my pocket to buy a {{ product.name }}."
And you create a product and parse the sentence:
@@ -21,7 +22,8 @@ puts Liquid::Template.parse(sentence).render('product' => my_purchase)sentence = "I'm running to the store with {{ product.price }} dollars in my pocket "
+sentence += "to buy a {{ product.name }}."
I'm running to the store with Liquid error: undefined method `to_liquid' for # dollars in my pocket to buy a Liquid error: undefined method `to_liquid' for #.
+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: