我基本上有一个动作,由于逻辑需要返回另一个 js 文件的内容。我该怎么做呢?谢谢
应用程序/控制器/classrooms_controller.rb
def create
if params[:test_logic]
respond_to do |format|
format.js { render 'create_differently' } # This doesn't work.
end
else
redirect_to root_path
end
end
app/views/classrooms/create_differently.js.erb
alert('hi')