[Facebooker-talk] Bug in Facebooker::Rails::Publisher
Rob Lacey
contact at robl.me
Wed Jun 3 10:32:32 EDT 2009
It does work for views in the folder of the publisher. I did look at
writing the test for the rendering partials as there doesn't appear to
be one only rendering inline. Although I am not quite sure how you're
testing this as the test RAILS_ROOT appears to be at the same depth as
the plugin e.g
./app/views/test/_publisher.erb
./facebooker
Shouldn't the test RAILS_ROOT be somewhere like test/rails_root/ or
something? I have pushed my changes, I'll send you over a pull request
shortly
http://github.com/braindeaf/facebooker/tree/master
RobL
http://www.robl.me
Mike Mangino wrote:
> 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