Rescue condition for model nil

This commit is contained in:
saurabhbhatia 2013-11-19 17:13:27 +08:00
parent fbb0bf6e04
commit 9178ebd793
1 changed files with 5 additions and 3 deletions

View File

@ -188,9 +188,11 @@ class PagesController < ApplicationController
@item = Item.where(:category => category_ids).first
else
if params[:action] && params[:action] == "show_from_link"
model = params[:app_action].classify.constantize
item = model.find(params[:id])
@item = Item.where(:category => [item.category_id.to_s]).first
model = params[:app_action].classify.constantize rescue nil
if !model.nil?
item = model.find(params[:id])
@item = Item.where(:category => [item.category_id.to_s]).first
end
end
end