olivernn / poirot

mustaches in your rails
http://olivernn.github.com/poirot
108 stars 21 forks source link

undefined method `view_renderer' #4

Closed dcu closed 12 years ago

dcu commented 13 years ago

I am getting this error with rails 3.0.10:

undefined method `view_renderer' for #<#<Class:0x0000000b9d2fc8>:0x0000000b9ccc90>

in

vendor/gems/poirot/lib/poirot/view.rb:41:in `assign_variables!'
olivernn commented 13 years ago

Could you give me a little more detail on this error. What were you trying to do when the error occurred, and what version of Poirot are you using?

danmayer commented 12 years ago

i am hitting something like this as well in Rails 3.0.6

poirot (0.0.3) lib/poirot/view.rb:40:in send' poirot (0.0.3) lib/poirot/view.rb:40:inassign_variables!' poirot (0.0.3) lib/poirot/view.rb:7:in initialize' app/views/users/_users_list.html.mustache:1:innew' app/views/users/_users_list.html.mustache:1:in _app_views_users__users_list_html_mustache___1993752031_2207653440_2031230' actionpack (3.0.6) lib/action_view/template.rb:135:insend' actionpack (3.0.6) lib/action_view/template.rb:135:in render' activesupport (3.0.6) lib/active_support/notifications.rb:54:ininstrument' actionpack (3.0.6) lib/action_view/template.rb:127:in render' actionpack (3.0.6) lib/action_view/render/partials.rb:333:inrender_partial' actionpack (3.0.6) lib/action_view/render/partials.rb:262:in render' activesupport (3.0.6) lib/active_support/notifications.rb:52:ininstrument' activesupport (3.0.6) lib/active_support/notifications/instrumenter.rb:21:in instrument' activesupport (3.0.6) lib/active_support/notifications.rb:52:ininstrument' actionpack (3.0.6) lib/action_view/render/partials.rb:260:in render' actionpack (3.0.6) lib/action_view/render/partials.rb:378:in_render_partial' actionpack (3.0.6) lib/action_view/render/rendering.rb:22:in render' app/views/users/index.html.erb:9:in_app_views_users_index_html_erb__1515899555_2207670280_0' actionpack (3.0.6) lib/action_view/template.rb:135:in send' actionpack (3.0.6) lib/action_view/template.rb:135:inrender' activesupport (3.0.6) lib/active_support/notifications.rb:54:in instrument' actionpack (3.0.6) lib/action_view/template.rb:127:inrender' actionpack (3.0.6) lib/action_view/render/rendering.rb:59:in `_render_template'

danmayer commented 12 years ago

updated to Rails 3.0.10 and I get the same thing...

poirot (0.0.3) lib/poirot/view.rb:40:in send' poirot (0.0.3) lib/poirot/view.rb:40:inassign_variables!' poirot (0.0.3) lib/poirot/view.rb:7:in initialize' app/views/users/_users_list.html.mustache:1:innew' app/views/users/_users_list.html.mustache:1:in _app_views_users__users_list_html_mustache___1993752031_2165237980_2035870' actionpack (3.0.10) lib/action_view/template.rb:135:insend' actionpack (3.0.10) lib/action_view/template.rb:135:in `render'

controller: def index @users = User.order('lower(name)').all end

view: app/views/index.html.erb

<%= render :partial => "users_list" %>

app/views/users/_users_list.html.mustache

dcu commented 12 years ago

it works on my repo, try it out

danmayer commented 12 years ago

It did work in your example project https://github.com/olivernn/notepad took awhile of digging since both my project and yours had gem 'poirot' in the Gemfile, but my project was bundle installing 0.0.3, while your project was getting 0.0.2. When I changed my project to gem 'poirot', '0.0.2' and bundled installed, then everything worked in my project. So it looks like there is a bug in 0.0.3 of poirot.

I will stay on 0.0.2 for now... to help debug 0.0.3 here are some additional details.

I added debug lines into the view.rb

  # get the locals from the view context, is there a better way?
  Rails.logger.info "*"*40
  Rails.logger.info view_context.inspect
  Rails.logger.info view_context.class

  locals = view_context.send(:view_renderer).send(:_partial_renderer).instance_variable_get("@locals") || {}

output:


 #<#Class:0x10b1fb5b0:0x10b1f9a08 @controller_path="site", @renderer=#      <ActionView::Partials::PartialRenderer:0x10b1f2fc8 @collection=nil, @path="check", @template=app/views/site/_check.html.mustache, @block=nil, @locals={:check=>nil}, @view=#<#Class:0x10b1fb5b0:0x10b1f9a08 ...>, @options={:partial=>"check"} ...
 #Class:0x10b1fb5b0
olivernn commented 12 years ago

Cool thanks for investigating this.

I think there were some quite big changes in the way view renderers work between Rails 3.0 and Rails 3.1. I tried to keep the gem working in both versions, but apparently this has failed.

@dcu is your repo at 0.0.3 or 0.0.2? Does it work in both Rails 3.0 and 3.1?

I'll try and get some time to get a more robust version out there, which will hopefully work in both Rails 3.0 and 3.1.

dcu commented 12 years ago

it works with both rails 3.0 and rails 3.1

olivernn commented 12 years ago

@dcu I'd be more than happy to accept a pull request with your changes to get poirot back working in both rails 3.0 and 3.1.

olivernn commented 12 years ago

I have released a new version which should work fine in both Rails 3 and Rails 3.1, if there are any issues please let me know.