我有以下表演动作:
def show
@name = params[:id]
rescue ActiveRecord::RecordNotFound
redirect_to :action => 'index'
@rpm = FedoraRpm.find_by_name(@name, :include => :rpm_comments)
@page_title = @rpm.name
end
即使我在那里添加了救援语句,它似乎也不起作用,当我尝试查看不存在的 URL 时出现此错误:
undefined method 'name' for nil:NilClass
我知道这可能与@page_title
变量有关,但我该如何解决呢?