formatで指定しても駄目だったので調べた。
ドキュメントに載ってなかったので、該当のメソッド読んだ結果
actionview-5.0.2/lib/action_view/renderer/partial_renderer.rb
# Sets up instance variables needed for rendering a partial. This method
# finds the options and details and extracts them. The method also contains
# logic that handles the type of object passed in as the partial.
#
# If +options[:partial]+ is a string, then the +@path+ instance variable is
# set to that string. Otherwise, the +options[:partial]+ object must
# respond to +to_partial_path+ in order to setup the path.
def setup(context, options, block)
@view = context
@options = options
@block = block
@locals = options[:locals] || {}
@details = extract_details(options)
prepend_formats(options[:formats])
partial = options[:partial]
(略)
formatsでOKっぽい。
<%= render :partial => "hoge", :formats => :js %>
と書けば良いっぽい。
actionview-5.0.2/lib/action_view/renderer/abstract_renderer.rb
def prepend_formats(formats)
formats = Array(formats)
return if formats.empty? || @lookup_context.html_fallback_for_js
@lookup_context.formats = formats | @lookup_context.formats
end
内部的にprepend_formats内で最初にArrayしてるのでオプション自体は配列でもそうでなくても良い様です。