我正在与Adhearsion和Rails合作。在我的Rails应用程序中,我在空闲时显示一个简单的主页。但是当调用不同的动作时,我需要重定向到其他控制器。日志说它成功重定向,但事实并非如此。 这是我试过的代码:
class TestController < ApplicationController
def index
end
def newcall
somevar = params[:some_param]
logger.info "A new call from"
logger.info somevar
logger.info "has been received"
redirect_to :controller => "flow2", :action => "index", :num => somevar
end
end
这是log / development.log
Processing TestController#newcall (for 127.0.0.1 at 2014-11-08 13:05:15) [GET]
Parameters: {"some_param"=>"9873193862"}
A new call from
9873193862
has been received
Redirected to http://localhost:3000/flow2?num=9873193862
Completed in 1ms (DB: 0) | 302 Found [http://localhost/test/newcall?some_param=9873193862]
但是尽管如此,我仍然坚持TestController的索引视图,而我现在想要查看Flow2 Controller。
非常感谢任何帮助。
编辑: Flow2Controller中的代码
def index
vnum = params[:num]
logger.info "Value of vnum"
logger.info vnum
new_user = Parent.find(:first, :conditions =>["f_number=? or m_number=?",vnum, vnum])
child_user = Student.find(:first, :conditions =>["number=?",vnum])
logger.info "done"
vdata = Callmetric.find(:all, :order=> 'created_at DESC', :limit=>10)
logger.info vdata.inspect
if !new_user.nil?
render :partial => 'show', :locals => {:number =>vnum, :data => vdata, :new_user=> new_user, :child_name=>child_user.name, :child_class=>child_user.classnum}
else
render :partial => 'second', :locals => {:number =>vnum, :data => vdata, :new_user=> new_user}
end
end