我有一个 Rails 应用程序,在 home
页面 home/index.html.erb
上,我显示了模型 workorders
的一部分。它当前默认为 home_controleer.rb
和 Action index
。
我可以选择 workorders_controller.rb
和 Action index2
吗?
我在 home/index.html.erb
View 文件中尝试了这个:
<%= render :partial => "workorders/index7", :controller => "workorders", :action => "index2" %>
但它不起作用。
最佳答案
试试这个:<%= render :template => "workorders/index2" %>
来源:https://stackoverflow.com/a/6051812/2128691
编辑 :回应您的最后一条评论...
我还没有真正使用过 bootstrap ,但也许你可以做这样的事情[伪代码]:
def home
if [x condition]
redirect_to index_seven_path
else
render :action => [y action]
end
end
关于ruby-on-rails - Rails : render partial with selected controller and action in view,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18320403/