From 9178ebd7938ce7e048fabbafd843455e250c1df0 Mon Sep 17 00:00:00 2001 From: saurabhbhatia Date: Tue, 19 Nov 2013 17:13:27 +0800 Subject: [PATCH] Rescue condition for model nil --- app/controllers/pages_controller.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 999fdbce..fec439ac 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -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