我嘗試通過傳遞控制器,動作和參數來重定向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