Rescue condition for model nil
This commit is contained in:
parent
fbb0bf6e04
commit
9178ebd793
|
@ -188,11 +188,13 @@ class PagesController < ApplicationController
|
||||||
@item = Item.where(:category => category_ids).first
|
@item = Item.where(:category => category_ids).first
|
||||||
else
|
else
|
||||||
if params[:action] && params[:action] == "show_from_link"
|
if params[:action] && params[:action] == "show_from_link"
|
||||||
model = params[:app_action].classify.constantize
|
model = params[:app_action].classify.constantize rescue nil
|
||||||
|
if !model.nil?
|
||||||
item = model.find(params[:id])
|
item = model.find(params[:id])
|
||||||
@item = Item.where(:category => [item.category_id.to_s]).first
|
@item = Item.where(:category => [item.category_id.to_s]).first
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@item = Item.root.children.where(:module_app_id => module_app.id).first unless @item
|
@item = Item.root.children.where(:module_app_id => module_app.id).first unless @item
|
||||||
end
|
end
|
||||||
|
|
Reference in New Issue