ruby 来自https://stackoverflow.com/questions/22078627/how-do-i-render-a-partial-from-the-rails-console

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby 来自https://stackoverflow.com/questions/22078627/how-do-i-render-a-partial-from-the-rails-console相关的知识,希望对你有一定的参考价值。

# initial setup
view_paths = Rails::Application::Configuration.new(Rails.root).paths["app/views"]
av_helper = ActionView::Base.new view_paths

# (Optional) include this if your partial uses route helpers:
include Rails.application.routes.url_helpers

av_helper.render "path/to/your/partial"

# Several options to use with render, for example render plain: | text: | html: | template: | partial: |

以上是关于ruby 来自https://stackoverflow.com/questions/22078627/how-do-i-render-a-partial-from-the-rails-console的主要内容,如果未能解决你的问题,请参考以下文章