我尝试通过传递控制器,动作和参数来重定向rails以显示动作。但是,rails完全忽略了动作的名称!Rails:redirect_to:controller =>'tips',:action =>'show',:id => @ tip.permalink
我得到的是 http://mysite/controllername/paramId
,所以我有错误讯息....
这里是我使用的动作代码:
def update
@tip = current_user.tips.find(params[:id])
@tip.attributes = params[:tip]
@tip.category_ids = params[:categories]
@tip.tag_with(params[:tags]) if params[:tags]
if @tip.save
flash[:notice] = 'Tip was successfully updated.'
redirect_to :controller=>'tips', :action => 'show', :id => @tip.permalink
else
render :action => 'edit'
end
end
我不知道有关:redirect_to上的通知快捷方式。谢谢,这肯定会节省一些时间。是否有相当于flash.now和render? – alternative 2010-06-12 11:06:31
使用武力,卢克 – Rimian 2011-05-26 11:15:27