[Facebooker-talk] Bug in Facebooker::Rails::Publisher

Mike Mangino mmangino at elevatedrails.com
Wed Jun 3 09:27:25 EDT 2009


That looks like a good fix. Does that work for views in the folder of  
the publisher? If so, send me a pull request on github to make sure  
you get credit for the change.

Mike

On Jun 3, 2009, at 5:25 AM, Rob Lacey wrote:

> Hi there,
>
> I've been trying to use the Facebooker::Rails::Publisher inside a  
> plugin and I noticed rendering views doesn't work since the view  
> paths are always app/views:app/views/<sub-class name>
>
> It appears that despite appending the view_paths to  
> ActionController::Base that the view paths that are passed to  
> ActionView::Base.new are [template_root, controller_root]. This  
> means any appended view_paths within the Rails application, and in  
> my case the plugin view paths, are missing.
>
> I fixed my problem by changing this from
> ActionView::Base.new([template_root,controller_root], assigns, self)
> to
> ActionView::Base.new(ActionController::Base.view_paths, assigns, self)
>
> def initialize_template_class(assigns)
>       template_root = "#{RAILS_ROOT}/app/views"
>       controller_root =  
> File.join(template_root,self.class.controller_path)
>       #only do this on Rails 2.1
>       if ActionController::Base.respond_to?(:append_view_path)
>         # only add the view path once
>         unless ActionController::Base.view_paths.include? 
> (controller_root)
>           ActionController::Base.append_view_path(controller_root)
>           ActionController::Base.append_view_path(controller_root 
> +"/..")
>         end
>       end
>       returning  
> ActionView::Base.new([template_root,controller_root], assigns, self)  
> do |template|
>         template.controller=self
>         template.extend(self.class.master_helper_module)
>         def template.request_comes_from_facebook?
>           true
>         end
>       end
>     end
>
> end
>
> I'm not sure what a more permanent solution would be. Any ideas?
>
> RobL
> http://www.robl.me
> _______________________________________________
> Facebooker-talk mailing list
> Facebooker-talk at rubyforge.org
> http://rubyforge.org/mailman/listinfo/facebooker-talk

--
Mike Mangino
http://www.elevatedrails.com





More information about the Facebooker-talk mailing list