我认为代码更明确
class RedirectController < ApplicationController
def index
redirect_to :controller => 'posts', :action => 'show', :id => 1
# it works
end
end
class RedirectController < ApplicationController
def index
render :controller => 'posts', :action => 'show', :id => 1
# it doesn't work
end
end
(B)可以在另一个控制器中加载另一个动作吗? (而不只是视图)怎么样? 谢谢
答案 0 :(得分:42)
尝试render 'posts/show'
或render :template => 'posts/show'
答案 1 :(得分:2)
只需渲染模板
string script = "$(document).ready(function () { $('[id*=form1]').load(); });";
ClientScript.RegisterStartupScript(this.GetType(), "load", script, true);
这个也有效
import { bootstrap } from '@angular/platform-browser-dynamic';
import { AppComponent } from './app.component';
import { disableDeprecatedForms, provideForms} from '@angular/forms';
bootstrap(AppComponent, [
disableDeprecatedForms(),
provideForms()
]);
如果您想要渲染其他布局
def index
render 'posts/show'
end