问题
I have a problem. I need to render objects using partials of another namespace.
render complain.target
it tryes to render partial from current namespace(current is admin
)
Missing partial admin/bulletins/bulletin...
I dont need to render it from admin/..
I cant specify partial path like
render partial: '/bulletins/bulletin', locals: { bulletin: complain.target }
But it's polymorphic association, and different partial pathes are used. Is it any way to do it? Thanks in advance!
回答1:
There seems to be no possible way to achieve this with a render complain.target
call (Checked on Rails 5 source).
There is a config option for action_view to disable namespace prepending for partials, though:
Rails.application.config.action_view.prefix_partial_path_with_controller_namespace = false
回答2:
You can use render "/#{complain.target.to_partial_path}"
来源:https://stackoverflow.com/questions/13376012/render-partial-of-another-namespace