[Facebooker-talk] Bug in Facebooker::Rails::Publisher
Rob Lacey
contact at robl.me
Wed Jun 3 05:25:04 EDT 2009
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
More information about the Facebooker-talk
mailing list