[liquid] undefined method `call' for LiquidView:Class

8 views
Skip to first unread message

hiddenloop

unread,
Jan 13, 2009, 7:58:44 PM1/13/09
to Liquid Templates
Hi,

- rails 2.2.2
- ruby 1.8.7 (2008-06-20 patchlevel 22) [i686-darwin9.3.0]
- liquid gem 1.90

Just trying to use the .liquid extension in my views, i've installed
the gem and added the init.rb file into rails initializers, when I
attempt to load a page with a .liquid view I get the error below.

Ive tried with both gem and plugin, same error in each case. Is there
a new way in Rails 2.2.2 to implement custom view extensions that
liquid isnt uptodate with perhaps? (using a self.call) ?

Any help appreciated,

Regards

Matt

NoMethodError (undefined method `call' for LiquidView:Class):
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/
renderable.rb:21:in `_unmemoized_compiled_source'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/
active_support/memoizable.rb:57:in `compiled_source'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/
active_support/memoizable.rb:25:in `__send__'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/
active_support/memoizable.rb:25:in `memoize_all'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/
active_support/memoizable.rb:22:in `each'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/
active_support/memoizable.rb:22:in `memoize_all'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/
active_support/memoizable.rb:17:in `freeze'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/
active_support/memoizable.rb:70:in `_pick_template'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/
base.rb:348:in `_exempt_from_layout?'

Cody Fauser

unread,
Jan 14, 2009, 8:53:33 AM1/14/09
to liquid-t...@googlegroups.com
Matt,

This is a known issue due to the template changes in Rails 2.2.2. A
fix is in the works.
--
Cody Fauser
http://shopify.com - e-commerce done right
http://www.codyfauser.com - blog
http://peepcode.com/products/activemerchant-pdf - ActiveMerchant PeepCode
http://www.oreilly.com/catalog/rjsrails - RJS Templates for Rails

hiddenloop

unread,
Jan 14, 2009, 1:03:15 PM1/14/09
to Liquid Templates
Ah, ok - i'll just use the regular parsing for now then.
--or if i've time, attempt to write a patch

Regards,

Matt

hiddenloop

unread,
Jan 17, 2009, 12:29:45 PM1/17/09
to Liquid Templates
If anyone is interested I have been able to patch the .liquid
extension to work with Rails 2.2.2 - this patch works with both the
gem (1.9.0) or latest from github, in either case try using the
following files;

config/initializers/liquid.rb => http://pastie.org/363312
lib/liquid_filters.rb => http://pastie.org/363315

Now you can use something like this in your controller actions;

def test
@posts = Post.find(:all)
render :template => 'posts/test.liquid', :locals => {'posts' =>
@posts}
end

Heres an overview of the changes I made;

liquid.rb

-- Overrides LiquidView and registers template handler
-- adds self.call method to LiquidView (needed for Rails 2.2.2)
-- includes ApplicationHelper - also hard-codes in a filter class to
use :filters => [LiquidFilters, (is there a better way of passing the
filters in?)
-- local_assigns now filled by local_assigns_for_rails_less_than_2_1_0
- or template.locals

liquid_filters.rb

-- Just a place to put you're filters for use in templates, example
shows with using something like number_to_currency

This is by no means an official liquid patch or anything. Any changes
or help with the above patch is appreciated.

Regards

Matt

hiddenloop

unread,
Jan 19, 2009, 8:20:22 PM1/19/09
to Liquid Templates
In reply to my own post, it seems this is enough to fix the problem
with Rails 2.2.2 and the .liquid extension;
config/initializers/liquid.rb => http://pastie.org/365287

You can then add your own filters with a regular call like,
Liquid::Template.register_filter(LiquidFilters)

m
> > > Cody Fauserhttp://shopify.com-e-commercedone righthttp://www.codyfauser.com-bloghttp://peepcode.com/products/activemerc...PeepCodehttp://www.oreilly.com/catalog/rjsrails-RJSTemplates for Rails
Reply all
Reply to author
Forward
0 new messages